Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need it to output Enter your speed (in kph): 90 Enter your tailgate distance (

ID: 3627079 • Letter: I

Question

I need it to output

Enter your speed (in kph): 90
Enter your tailgate distance (in meters): 700
Major wreck!

/***************************************************************
* Speed
*
* This program determines if a vehicle’s tailgating distance is safe.
**************************************************************/
import java.util.Scanner;
public class Speed
{ //start class
public static void main (String [] args)
{ //start main
Scanner stdln = new Scanner (System.in);
double speed; //speed of car
double tailgatingDistance; //taligate distance
double stoppingDistance; //stopping distance

System.out.print ("Enter your speed in kph:");
speed = stdln.nextDouble ( );
System.out.print ("Enter tailgating distance in m :");
tailgatingDistance = stdln.nextDouble ( );
System.out.println (stoppingDistance = speed *2.25 + speed /21);
if (stoppingDistance < tailgatingDistance)
{
System.out.println ("No problem.");
}
if (stoppingDistance == tailgatingDistance)
{
System.out.println ("Minor wreck.");
}
if (stoppingDistance > tailgatingDistance)
{
System.out.println ("Major wreck!");
}
} // end main
} // end class Speed

Explanation / Answer

// working perfectly now ..Enjoy.

import java.util.Scanner;
public class MiddendorfDougProg4
{ //start class
public static void main (String[] args)
{ //start main
Scanner stdln = new Scanner (System.in);
double speed; //speed of car
double tailgatingDistance; //taligate distance
double stoppingDistance; //stopping distance

System.out.println("Enter your speed (in mph):");
speed = stdln.nextDouble();
System.out.println("Enter tailgating distance (in feet) :");
tailgatingDistance = stdln.nextDouble ( );
stoppingDistance = speed * (2.25 + speed / 21);
if (stoppingDistance < tailgatingDistance)
{
System.out.println ("No problem.");
}
if (stoppingDistance == tailgatingDistance)
{
System.out.println ("Minor wreck.");
}
if (stoppingDistance > tailgatingDistance)
{
System.out.println ("Major wreck!");
}
} // end main
} // end class Speed