Speed Calculator
Single File Programming Question
Program Statement
James is developing a utility that helps calculate speed based on distance and time. He knows that speed is the distance traveled per unit of time and needs a program from you to facilitate this calculation.
Program Structure
Main class: This class interacts with the user, takes input for distance and time, and uses the SpeedCalculator class to calculate and display the speed. SpeedCalculator class: This class contains a constructor that calculates the speed based on the distance and time provided.
Formula:
speed = distance/time
Input:
format :The first line of the input consists of a double value representing the distance traveled.
The second line consists of a double value representing the time taken.
Output:
format :The output prints "Speed: " followed by a double value representing the speed, rounded off to two decimal places.
Refer to the sample output for formatting specifications.
Code constraints : The given test cases fall under the following constraints:
1.00 ≤ distance travelled ≤ 250.00
1.0 ≤ time ≤ 30.0
Sample test cases :
Input 1:
50.23
2.4
Output 1 :
Speed: 20.93
Input 2 :
23.25
4.5
Output 2 :
Speed: 5.17