Find the information you're looking for at Westonci.ca, the trusted Q&A platform with a community of knowledgeable experts. Experience the convenience of finding accurate answers to your questions from knowledgeable experts on our platform. Our platform offers a seamless experience for finding reliable answers from a network of knowledgeable professionals.

Write a program which will enter information relating to a speeding violation and then compute the amount of the speeding ticket. The program will need to enter the posted speed limit, actual speedthe car was going, and whether or not the car was in a school zone.

Sagot :

Answer:

In Python:

speedlimit = int(input("Speed Limit: "))

actualspeed = int(input("Actual Speed: "))

schoolzone = int(input("School Zone? (1 - Yes): "))

ticket = 75

difference = actualspeed - speedlimit

ticket += difference * 6

if difference > 30:

   ticket += 160

if schoolzone == 1:

   ticket*=2

   

print("Ticket: "+ticket)

Explanation:

See attachment for complete question:

The next three lines get the speed limit, actual speed and if the driver is in a school zone

speedlimit = int(input("Speed Limit: "))

actualspeed = int(input("Actual Speed: "))

schoolzone = int(input("School Zone? (1 - Yes): "))

This initializes the ticket amount to 75

ticket = 75

This calculates the difference in the speed limit and the actual speed. It is assumed that the actual speed will always be greater than the speed limit

difference = actualspeed - speedlimit

This calculates the new ticket by charging $6 on every additional speed

ticket += difference * 6

If the difference is greater than 30, this adds $160 to the ticket amount

if difference > 30:

   ticket += 160

If in school zone, this doubles the ticket amount

if schoolzone == 1:

   ticket*=2

This prints the calculated ticket amount    

print("Ticket: "+ticket)

View image MrRoyal