I am needing to write a program: stoppingDistance = speed * (2.25 + speed / 21)
ID: 3624910 • Letter: I
Question
I am needing to write a program:
stoppingDistance = speed * (2.25 + speed / 21)
The program should then calculate the distance that would be required to stop the vehicle.
- If the stopping distance is less than the tailgating distance, your program should print "No problem."
- If the stopping distance equals the tailgating distance, your program should print "Minor wreck."
- If the stopping distance is greater than the tailgating distance, your program should print "Major wreck!"
Use type double for your working variables.
This is what I got but it will not compile. Saying that I have 2 errors. I don't even know if I'm writing the code right.
-------------------Code below-----------------
/******************************
* Tailgating.java
*
*
*
*
*******************************/
import java.util.Scanner;
public class Tailgating
{
public static void main(String [] args)
{
Scanner stdIn = new Scanner(System.in);
String response;
System.out.print("Enter speed in mph: ");
speed = stdIn.nextDouble();
System.out.print("Enter tailgate distance in feet:");
distance = stdIn.nextDouble();
stoppingDistance = speed * (2.25 + speed / 21);
if (stoppingDistance < distance)
{
System.out.println("No problem.");
}
else if (stoppingDistance == distance);
{
System.out.println("Minor wreck.");
}
else (stoppingDistance < distance);
{
System.out.println("Major wreck!");
}
} // end main
} // end class