Question: Write a program that is given two integers representing a speed limit and driving speed in miles per hour ( mph ) and outputs the

Write a program that is given two integers representing a speed limit and driving speed in miles per hour (mph) and outputs the traffic ticket amount. We will need to use a series of if/elif/elif/elif/else statements to complete this program. You will be comparing the difference (driving speed - speed limit) to each condition below
These are the conditions (take your time and do them one by one!):
Driving faster than 40 mph over the speed limit receives a $300 ticket.
Driving 21-40 mph over the speed limit receives a $150 ticket.
Driving 6-20 mph over the speed limit receives a $75 ticket.
Driving 10 mph under the speed limit (or slower) receives a $50 ticket.
Otherwise, no ticket is received.
Ex: If the input is (speed limit and then driving speed):
35
45
the output is:
75
because the driver was driving 10 miles over the speed limit, which falls in between 6-20 miles over the speed limit.
Ex: If the input is:
35
26
the output is:
0
because the driver was driving 9 miles under the speed limit, which means no ticket is issued.
Ex: If the input is:
55
80
the output is:
150
because the driver was driving 25 miles over the speed limit, which falls in between 21-40 miles over the speed limit.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!