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

This problem uses java: In this problem, you will write a program that computes

ID: 3617476 • Letter: T

Question

This problem uses java:


In this problem, you will write a program that computes distancetravelled. The distance a vehicle travels can be calculated asfollows:     Distance = Speed * Time;
For example, if a car travels 50 miles-per-hour for three hours,the distance travelled is 150 miles.

Write a program that asks the user for the speed of a vehicle(in miles-per-hour) and the number of hours it has travelled. For this, write a method named distance thataccepts the vehicle’s speed and time as arguments, andreturns the distance the vehicle travelled.

                               ….   distance (double speed, double time){...}

The program should display the distance a vehicle has travelledfor each hour of a time period specified by the user. Forexample, a vehicle that travelled 50 mph for 3-hour time period, itshould display a report similar to the following table:

               Hour                                     Distance Travelled

               1                                                             50

               2                                                             100

               3                                                             150                                                        

The program should not stop afterone computation, but it should continueexecuting (looping) and ask the user to continue orquit. Input Validation: The programmust not accept a negative number for speed and do not accept anyvalue less than 1 for time travelled.

Explanation / Answer

please rate - thanks import java.util.*; public class untitled { public static void main(String args[]) {int distance,speed,time,i; Scanner in=new Scanner(System.in); char cont='y'; while(cont=='y'||cont=='Y') { System.out.print("Enter the vehicles speed "); speed=in.nextInt(); while(speed
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote