Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Assuming there are no accidents or delays, the distance a car travels down the interstatecan be calculated with the following formula:Distance = speed x timeWhile
Assuming there are no accidents or delays, the distance a car travels down the interstatecan be calculated with the following formula:Distance speed x timeWhile the length of a trip would be calculated byTime distancespeedIn addition, lets assume the following are true:For every hours of travelling, speeding cars can get a ticket depending on howfast they are going. If they travel more than km per hour the ticket is $ while if theytravel more than km per hour it costs $Every hour of travelling consumes, on average, liters of gas for your make andmodel of car.Gas currently costs $ per literWrite a simple program that takes as input, the speed you plan to travel no need to input the distance and then outputs how long and how expensive it will be to travel thefollowing constant distances:
km
km
km
Your solution must also do the following: Validate these the user input speed meets some logical criteria that you decide.hint: can you travel negative KMhour Still meet all expectations for style, comments and clarity in code. Use constants where appropriate. Provide a descriptive user experience eg if something goes wrong, the usershould be told what they did wrong so they can fix it in the futureTo help you succeed, a car travelling KMhour would expect to produce the followingoutputs:km hours for a cost of no ticketskm hours for a cost of no ticketskm hours for a cost of no tickets
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started