Where have I gone wrong

Using the Java SDK with TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
eriknox
Posts: 3
Joined: Wed Sep 09, 2009 7:59 pm

Where have I gone wrong

Post by eriknox »

It compiles right with exit code 2 no errors..Yes this is for a class but it is online and it's difficult for her to get back to us. Also, where can I find out what the exit codes stand for. Any help would be great. Thanks

import java.util.Scanner;
public class ErikKnoxProg4
{
public static void main(String[] args)
{
Scanner stdln=new Scanner(System.in);
double speed, distance, stoppingDistance; //formula numbers
System.out.print("Enter your speed (in mph):"); //Print and wait for response
speed = stdln.nextDouble();
System.out.print("Enter your tailgate distance (in feet):");//print and wait for response
distance = stdln.nextDouble();
stoppingDistance = speed * (2.25 + speed / 21);//Process the user input


if (stoppingDistance > distance)
{
System.out.println("Major wreck!");
}
else if (stoppingDistance == distance)
{
System.out.println("Minor wreck.");
}
else
{
System.out.println("No problem.");
}
}//end if
}//end main
User avatar
talleyrand
Posts: 624
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

So what's the problem?

C:\tmp>"\Program Files\Java\jdk1.5.0_11\bin\javac.exe" ErikKnoxProg4.java

C:\tmp>"\Program Files\Java\jdk1.5.0_11\bin\java.exe" ErikKnoxProg4
Enter your speed (in mph):10
Enter your tailgate distance (in feet):10
Major wreck!
I choose to fight with a sack of angry cats.
Post Reply