Question: A radar speed gun is a device used in law - enforcement to measure the speed of moving vehicles in miles per hour. The measured

A radar speed gun is a device used in law-enforcement to measure the speed of moving vehicles in miles per hour. The measured speeds are supposed to be stored in a file, one number per line, as follows:
65.6
70.2
54.9
Unfortunately, due to an intermittent fault, occasionally multiple numbers are written on a single line as follows:
73.265.669.8
Furthermore, occasionally the radar gun outputs a single stray character such as: 67.9z,6$4.9, or a3.9, to illustrate just a few.
Given a file that has radar speed gun readings, write a function averageSpeed() to calculate the average of the numbers in the file. Your code must adhere to the following specifications:
a.Prompt the user for the name of the input file to process. When the user enters a nonexistent file name, give the user a second chance. After two wrong entries in a row, quit the program with an appropriate message.
b. Ignore numbers containing stray characters.
c. Ignore any reading for slow vehicles moving at 2 miles per hour or less.
d. Print the final average to the console.
e. Make use of the functions safeOpen() and safeFloat()

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 Programming Questions!