Page 1 of 1

Where have I gone wrong

Posted: Wed Sep 09, 2009 8:46 pm
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

Posted: Mon Sep 14, 2009 6:24 pm
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!