Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Programming Language is Python Programming Project 3: Text Files and Traffic Tickets Object of this exercise: use functions, loops, and lists to read and

image text in transcribedimage text in transcribedimage text in transcribedThe Programming Language is Python

Programming Project 3: Text Files and Traffic Tickets Object of this exercise: use functions, loops, and lists to read and process data in a text file. NO Globar Your program should use a loop to read traffic ticket information from a data file containing 30 tab-separated Variables records. Each record has the offender's name, the ticketed speed, and the posted speed limit for a given citation. For example, citizen Davis was ticketed for going 76 mph in a zone with a posted speed limit of 55 mph. Citizen Wilson was doing 64 mph in a 45 mph zone. As shown... 55 45 Davis 76 Wilson 64 Syler 56 ... and so on 35 Your program should read the data file and calculate the fine for each offender based upon the following fine structure: for a violation of less than 5 mph over the limit, the fine is $65 for a violation of between 5 and up to but not including 10 mph over the limit, the fine is $85 for a violation of between 10 and up to but not including 15 mph over the limit, the fine is $120 for a violation of between 15 and up to but not including 25 mph over the limit, the fine is $150 for a violation of 25 mph or more over the limit, the fine is $200 For each record, your program should print the name, calculate and print the number of miles-per-hour over the posted limit, and also calculate the fine for each record. After printing all 30 records, you need to print the count of the total number of fines for each fine category based on this data. The tab-separated text file you need to use can be accessed using this link: speeds.txt. Copy the speeds.txt file to the folder where your program will reside. So, your output should look something like the following, but with all 30 records and an accurate count for the number of tickets per category. For example, there were no tickets issued for less then 5 mph over, but there were 3 tickets issued for between 5 and 10 mph, and 4 tickets issued for between 10 and 15 mph. So, the top part of your print out of the data will contain the name, mph over, and fine for each of the 30 offenders, and after all 30 have been printed you need to print the count for each ticket category. I will leave it up to you to figure out how many tickets were given in the last two categories. Name MPH Over Fine Davis 21 Wilson 19 Syler 21 Green 17 Smith ...and 25 more 150 150 150 150 200 Tickets less than 5 mph over: 0 Tickets between 5 and 10 mph over: 3 Tickets between 10 and 15 mph over: 4 Tickets between 15 and 25 mph over ? Tickets greater than 25 mph over: ? To get full credit your program needs to accomplish the following. Your code needs to read the traffic ticket data from the supplied text file. Do not modify the file, it needs to keep its current structure. You need to print each offenders name, number of mph over the posted limit for that offender, and the amount of the fine for that person. Printouts need to be neat and properly aligned, where the names are left justified, and the MPH over and fine values are right justified and line up in straight columns, as shown above. The part of the printout containing the count of tickets in each category does not need to be formatted into columns unless you just want to. You need to process the data with a loop, and that loop should be able to work properly even if the number of citations in the file varies from day to day. That is, don't use 30 as a magic number. The program should work no matter how many records the file might contain. Your program must have at least 2 functions written by you. A main() function, and a function to determine mph over and/or the fine. The main function should contain the loop that reads the data. You could easily have more than 2 functions if you choose, but you need 2 minimum. The non-main function should do the mph-over calculation. It might also do the fine determination. Or you may have separate functions for each. This will require passing an argument (or augments) or returning a value, or both. Knowing how to do arguments/return values is a goal of the exercise. 55 45 35 55 25 45 55 Davis Wilson Syler Green Smith Washt Harly Adams Monroe Bailey Smith Balmer Court Renee Brown Cooper Davis DeMato Denham Feller Geisly Hartly Johan Johns Kamler Marbry Roby Truel Tyler Perry 76 64 56 72 72 61 80 42 67 75 83 43 62 47 81 53 61 102 78 68 64 85 67 72 51 69 39 99 57 80 35 55 45 55 35 45 25 55 35 55 45 55 55 45 35 45 55 35 45 25 55 45 55

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions