import java.util.Scanner; class SDTCalc{ public static void main(String [] args){ Scanner jack = new Scanner(System.in); System.out.println("Are you looking for Speed, Time or Distance? "); String target = jack.nextLine(); double dist; double speed; double time; if (target == "Speed" || target == "speed") { System.out.println("Please enter a value for Distance (kilometres): "); dist = jack.nextDouble(); System.out.println("Please enter a value for Time (hours): "); time = jack.nextDouble(); System.out.println(dist/time + " km/h"); } else if(target == "Distance" || target == "distance") { System.out.println("Please enter a value for Speed (km/h): "); speed = jack.nextDouble(); System.out.println("Please enter a value for Time (hours): "); time = jack.nextDouble(); System.out.println(speed*time + " km"); } else if(target == "Time" || target == "time") { System.out.println("Please enter a value for Speed (km/h): "); speed = jack.nextDouble(); System.out.println("Please enter a value for Distance (hours): "); dist = jack.nextDouble(); System.out.println(dist/speed + " hours"); } } }
Appreciate all help, truly, only new but eclipse isn't showing me up any errors yet the program just won't run at all for me? Shows the first line of text then terminates.
Thanks to anyone that will give me any help with this, you truly would be helping me out big time!
Jack
EDIT: Sorry, thought it would have registered the indents too, hopefully ye can still make it out