Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program to be written in C++. Please refer to the outputs above to write the code in the exact same format. Question #1: Speed System

image text in transcribed

image text in transcribed

image text in transcribed

Program to be written in C++.

Please refer to the outputs above to write the code in the exact same format.

Question #1: Speed System Program (6 pts) In this question, you will write a program that determines the penalty of a driver who is speeding on highway with the speed limit of 100km/h based on Ontario Courts. Your program should follow the following rules: Prompt the user to enter name, id and score and validates the information. The student name should be entered as "LastName, FirstName" (separated by comma). Please note the whole name should be saved in one string. The driver ID must have 7 digits. The driver's SPEED must greater than 0. If the user enter correct information, your program should display the fine based on the speed. When the fine is displayed, the output should be "FirstName LastName got SPEED. Based on the speed system, FirstName (ID) will pay X." Please note the calculation of X is based on the following rules: - A $2.50/km speeding fine for 1-19km/h over the speed limit. - A $3.75/km speeding fine for 20-29km/h over the speed limit. - A $6.00/km speeding fine for 30-49km/h over the speed limit. 50+ km/h over the speed limit comes with a court decided fine. Your program should be able to ask user for new input of driver's information for penalty until get the input Yes from the user. Display welcome & closing messages. Assignment #2 Comp 218/Winter 2021 Page 2 of 7 program must display the same information with the same format. User input at the keyboard is marked with a red circle. Welcome to Speed System Program! Please enter your name (Lastname, Firstname seperated by comma): Liu, Tom Please enter your ID without any spaces (7 digits): 9090901 Please enter your speed: 110 Tom Liu got 110. Based on the speed system, Tom (9090901) will pay $25 Exit the program? (enter Yes to exit): No Please enter your name (Lastname, Firstname seperated by comma): Hans, Lucy Please enter your ID without any spaces (7 digits): 2314512 Please enter your speed: 125 Lucy Hans got 125. Based on the speed system, Lucy (2314512) will pay $93.75 Exit the program? (enter Yes to exit): No Please enter your name (Lastname, Firstname seperated by comma): Thame, Lin Please enter your ID without any spaces (7 digits): 2345678 Please enter your speed: 90 Lin Thame got 90. Based on the speed system, you do not need to pay any fine!! Exit the program?(enter Yes to exit): Yes Thank you for using Speed System Program! Welcome to Speed System Program! Please enter your name (Lastname, Firstname seperated by comma): Derek,Hulo Please enter your ID without any spaces (7 digits): 123 Please enter your ID without any spaces (7 digits): 1234567 Please enter your speed: 180 Hulo Derek got 180. Based on the speed system, the court will decide your fine!! Exit the program? (enter Yes to exit): No Please enter your name (Lastname, Firstname seperated by comma): Chen, Lily Please enter your ID without any spaces (7 digits): 2131412 Please enter your speed: 120 Lily Chen got 120. Based on the speed system, Lily (2131412) will pay $75 Exit the program?(enter Yes to exit): Yes Thank you for using Speed System Program! Figure 2 Sample output of Question#1

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions