Question: 2. (Design/Problem Solving) Create an algorithm for a program that simulates the fines issued to drivers based on speeds recorded by a police radar gun.

2. (Design/Problem Solving) Create an algorithm for a program that simulates the fines issued to drivers based on speeds recorded by a police radar gun. The algorithm should read the recorded automobile speed (in km/h) as an integer and print the message "Speeding" if the speed exceeds 60 km/h or "Not Speeding" if the speed 60 km/h or less. The algorithm should then calculate the appropriate fine (if applicable). If the speed is 5 km/h or less over this limit, only issue a warning. If the speed is more than 5 and no more than 10 km/h above the limit, the fine is $80. For a speed of more than 10 but no more than 20 km/h above the limit, the fine is $150. For a speed of more than 20 km/h above the limit, the fine is $500 You should give some thought as to the type of data you are working with before beginning to design your solution. You should also consider what to do if a negative number is input. Speed cameras do not register negative numbers, so they should not be accepted as input. Note: data type is assumed to be int (.e. and integer); for the purpose of this exercise, DO NOT use floating point numbers, Also, 60 or less means the speed can be 60 but no more; this is not speeding. Exceeds 60 means the speed is over 60 and therefore speeding. This same logic applies when considering the other speed categories and can be viewed as follows: 61-65 inclusive = warning 66-70 inclusive = $80 71-80 inclusive = $750 81 or more $500 4. (Programming exercise) Implement your algorithm from question 2 into a C program. When developing your program pay particular attention to the use of constant values in your program. Identify what values for this problem should be constants and define them using the const keyword. Ideally you should find that you have very few actual numbers (called "literal values) in your program apart from when defining constants. (The obvious exception to this is the use of zero to initialise variables etc.) Run the program and test it by applying the test data from your test table, and fill in the remainder of the test table (i.e. last column)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
