Screen capture of the program execution (i want it like this form): A local Road
ID: 3730926 • Letter: S
Question
Screen capture of the program execution (i want it like this form):
A local Road Safety Department is tasked with monitoring and issuing speeding tickets and warnings for drivers who violate the 120 km/hr speed limit. Write a complete C+t program that reads the travelled distance of a car in km (as integer) and the elapsed time in minutes (as integer). The program should compute the speed of the car and issue violation ticket if the driver exceeds the speed limit. The program must distinguish between private small vehicles ('S"), large commercial trucks (T"), and government owned ones ('G'). Your program should perform the following tasks o Prompt the user to enter the type of the car (S, T, or G) Prompt the user to enter the travelled distance o Prompt the user to enter the elapsed time o Convert the time from minutes to hours. (e.g. 90 minutes - 1.5 hours) o Compute the speed as the travelled distance divided by the time in hours. o Check if the driver violated the speed limit of 120 km/hr and issue speed violation ticket/notices/action according to the following table Speed Speed Violation fee Between 120 and 140 km/hour Between 140 and 160 km/hour More than 160 km/hour 10 OMR 30 OMR 50 OMR, and driver's licence is suspended Notify the government violation 20 OMR 60 OMR 100 OMR, and nstitution of the driver s licence is suspended Less than or equal to 120 0 OMR No violationExplanation / Answer
ScreenShot
---------------------------------------------------------------------------------------------------------------------------
Code:-
//Header Files
#include<iostream>
#include <cctype>
using namespace std;
//Main method
int main()
{
//Variable declaration
char carType;
int distance,time,speed;
double timeH;
//Welcome message
cout << " Alsalam Alaikum"<<endl;
cout << " Welcome To The Speeding Ticket System"<<endl ;
cout << " --------------------------------------" << endl<<endl;
//Prompt user to enter car type
cout << " Please enter the car type " << endl;
cout << " [S:Small ; T:Truck ; G:Goverment]" << endl;
cout << " ((or other character to cancel)) : " ;
cin >> carType;
//If cartype is s,t or g accept, otherwise exit
if (toupper(carType) == 'S' || toupper(carType) == 'T' || toupper(carType) == 'G') {
//prompt user for distance
cout << endl << " Please enter the distance travelled by the car: ";
cin >> distance;
//Prompt for elapse time
cout << " Please enter the travelled time in minute: ";
cin >> time;
//Convert time into hour
timeH = (double)time / 60;
//display travelled distance in time
cout << endl << endl << " The car travelled " << distance << " km in " << timeH << " hr";
//calculate speed
speed = distance / timeH;
}
else {
exit;
}
//condition to the type of cars
switch (toupper(carType))
{
//condition and calculation for small vehicle
case 'S':
if (speed <= 120) {
cout <<endl<< " The car was within the driving speed limit, no action is to be taken...";
}
else if (speed > 120 && speed<140) {
cout << endl<<" The car was over speeding by "<<speed-120<<" km/hr, and his/her fine is 10 OMR";
}
else if (speed > 140 && speed<160) {
cout << endl<<" The car was over speeding by " << speed-120 << " km/hr, and his/her fine is 30 OMR";
}
else {
cout <<endl<< " The car was over speeding by " << speed-120 << " km/hr, and his/her fine is 50 OMR";
cout <<endl<< " Driver's licence is suspended .... report to the department";
}
break;
//condition and calculation for truck
case 'G':
if (speed <= 120) {
cout << endl << " The car was within the driving speed limit, no action is to be taken...";
}
else if (speed > 120 && speed<140) {
cout << endl << " The car was over speeding by " << speed-120 ;
cout << endl << " Report the violation to the goverment institution";
}
else if (speed > 140 && speed<160) {
cout << endl << " The car was over speeding by " << speed - 120;
cout << endl << " Report the violation to the goverment institution";
}
else {
cout << endl << " The car was over speeding by " << speed - 120;
cout << endl << " Report the violation to the goverment institution";
}
break;
//condition and calculation for Government vehicle
case 'T':
if (speed <= 120) {
cout << endl << " The car was within the driving speed limit, no action is to be taken...";
}
else if (speed > 120 && speed<140) {
cout << endl << " The car was over speeding by " << speed -120<< " km/hr, and his/her fine is 10 OMR";
}
else if (speed > 140 && speed<160) {
cout << endl << " The car was over speeding by " << speed-120 << " km/hr, and his/her fine is 30 OMR";
}
else {
cout << endl << " The car was over speeding by " << speed-120 << " km/hr, and his/her fine is 50 OMR";
cout << endl << " Driver's licence is suspended .... report to the department";
}
break;
default:
break;
}
//Thank you prompt
cout << endl << endl << " Thanks, Good Bye ......" << endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.