In: Computer Science
Question 1 In this exercise, you are required to do a program analysis and write a program for a system that computes a speeding ticket cost. The charge is calculated as follows: P20 for every kilometre above the speed limit, plus P100 standard charge. E.g. If the speed limit is 60 km/hour and you are driving at 75 km/hour. The charge will be P400. If the speed is equal to or under the speed limit, then there is no charge. However, if the speed is over 220 km/hour in a 60 km zone the license is immediately revoked plus P3000 pula fine, but if it is the driver’s birthday the ticket will be forgiven and cost nothing. The output should be both to the screen and word document file. Required: Part A: Documentation Compile a well-structured report that contains the following information. 1. Problem definition 2. System Requirements 3. Flowchart for the system 4. Results and Discussions 5. Conclusions 6. Referencing [50 marks] Part B: C++ Program Write a C++ program for the system. Assessment will be through demonstration. [50 marks]
main.cpp
#include <iostream>
using namespace std;
int main() {
int limit,speed;
cout<<"Welcome to Speed Ticketing"<<endl;
cout<<"Please enter the speed limit: "<<endl;
cin>>limit;
cout<<"Please enter the speed you were driving at: "<<endl;
cin>>speed;
int finalSpeed = speed-limit;
cout<<"Is today your birthday?(Please answer 'Y-for Yes' or 'N-No')"<<endl;
char ch;
cin>>ch;
if (ch == 'N'){
if(speed>limit){
if(finalSpeed>=160){
cout<<"Your licence is being revoked along with a fine of P3000."<<endl;
}
else{
int fine = (finalSpeed*20) + 100;
cout<<"You are fined with total: P"<<fine<<endl;
}
}
}
else{
cout<<"You are good to go!!!!"<<endl;
}
}
Output: