Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

SIDE NOTE: PLEASE USE C++, thank you in advanced uestion 1 - Nested selection st

ID: 3725957 • Letter: S

Question

SIDE NOTE: PLEASE USE C++, thank you in advanced

uestion 1 - Nested selection statements (if/else-switch The Quebec government is trying to crack down on texting and driving. "The law is very clear: you must not hold a cell phone in your hand while driving. Failure to abide by this rule is an offence subject toa Write a program that determines the penalty for a driver holding a cell phone while driving based on Nancy's Crazy criteria If the driver is driving and holding a cell phone On the highway the fine is $80. If it is the drivers 1st offence s/he gets 1 demerit point otherwise 2 demerit points In a school zone the fine is $100 (the maximum). If the driver has been driving for less than 24 months s/he loose his/her license on the spot otherwise s/he get 4 demerit points (the maximum) If the car is stopped, for example at a stop sign or a traffic light, and the cellphone is an iPhone, the fine is $100 and s/he gets 2 demerit point otherwise the fine is $80 and s/he gets 1 demerit points. (Crazy Nancy does not like iPhones.) All other cases the fine is $90 and the driver gets 3 demerit points After determining where the driver was stopped and what their fine if they have not yet lost their license, ask the user how many demerit points the driver originally had. When a driver has 12 demerit points they lose their license. Determine if the driver should lose their license given where they were when they were holding their cell phone. Output how many demerit points the driver now has Assume you have a perfect user who enters valid input The following are recommended statements for solving this problems: switch, if/else and nested if/else. Here are a few sample outputs to illustrate the expected behavior of your program Weleone to the Fine and Denerit Point Evaluatert er t.cforeteleu vhat the fine and denerit w leone 0fF icer one iafornat lon hefere I tel1 yu what the fine and denerit peinES AP iver ua,stepped the highway Ner stepped a the kigay is stepped at a Stop sign or traffie light ..tepped at Stop .ign or traffic light lease enter the digit corresponding to your case Efieer- is this the driver' 1st offence rite a ticket fer $08 and inforn the driver that they nou have 6 denerit points ood jab efficert Crary Naneys tells you to heep up the geod werkt -) uvite a ticket fo$8 and inform the driver that they hawe 1.denerit points. jeb officert Crazy Hancy" te1ls you te heep up the geed vrkttt based on Craay HeasysCriteria oKerrinfornat ion lefere I sel hat the fine and deneri ein iver yas stopped ee the kiuay Car is stepped at a Stop sign or traffie light lease enter the digit carrespending to your cas questian officert Bau nany denerit points did driver have riar t heing steppedT Offic.r. write a ticket far tie take aus, their dever'. 1&cense; and make arrange"est. to have the cap tas e oed jeb off icert Craay Nancy'tells you to keep up tle seed vorkft1

Explanation / Answer

#include <cstdlib>
#include <iostream>
#include<iomanip>

using namespace std;
void display_menu();//prototype to display the menu

int main(int argc, char** argv) {

int choice;//for accepting user choice
  
char offence;//for accepting offence count
int demerit;//for assigning demerits count
int drive_month;//for assigning the driver driving month
char iphone;//for assigning values to the iphone users
  
//do loop is used to perform the operation until the user exit
do{
display_menu();//displays the menu
  
//prompt for user input of choice
cout<<"Please Enter the digit corresponding to your case :";
cin>>choice;
  
//switch case is used to select the option entered by the user
switch(choice){
case 1://if choice is 1
//prompt the user for first time or not
cout<<"Officer, is this the driver's 1st offence (answer with y for yes and anything else for no) :";
cin>>offence;
//if y then demerit is 1 else accept demerit and add the points to it
if((offence=='y')||(offence=='Y')){
demerit= 1;
}
else{
cout<<"Last Question officer! How many demerit points did the driver have prior to being stopped?";
cin>>demerit;
demerit = demerit+2;
}
//display the result
cout<<"Write a ticket for $80 and inform the driver that they now have "<<demerit<<" demerit points."<<endl;
break;
case 2://if the option is 2
cout<<" How many months has the driver been driving?";
cin>>drive_month;
if(drive_month<24){//if driver drives less than 24 the cancel the lisences or demerit the point
cout<<"write a ticket for $100 and take their license"<<endl;
}
else{
cout<<"Last Question officer! How many demerit points did the driver have prior to being stopped?";
cin>>demerit;
demerit = demerit+4;
cout<<"Write a ticket for $100 and inform the driver that they now have "<<demerit<<" demerit points."<<endl;
}
break;
case 3://if the option 3
cout<<" Officer, is the cellphone is iphone(answer with y for yes and anything else for no)?";
cin>>iphone;
int amt;
if((iphone=='y')||(iphone=='Y')){//if the user uses iphone
amt = 100;
cout<<"Officer, is this the driver's 1st offence (answer with y for yes and anything else for no) :";
cin>>offence;
if((offence=='y')||(offence=='Y')){//if the user's offence is first time
demerit= 2;
}
else{//if the user uses iphone and offences not first time then else is performed
cout<<"Last Question officer! How many demerit points did the driver have prior to being stopped?";
cin>>demerit;
demerit = demerit+2;
}
}
else{//if not iphone the else is performed
amt = 80;
cout<<"Officer, is this the driver's 1st offence (answer with y for yes and anything else for no) :";
cin>>offence;
if((offence=='y')||(offence=='Y')){
demerit= 1;
}
else{
cout<<"Last Question officer! How many demerit points did the driver have prior to being stopped?";
cin>>demerit;
demerit = demerit+1;
}
}
cout<<"Write a ticket for $"<<amt<<" and inform the driver that they now have "<<demerit<<" demerit points."<<endl;
break;
case 4://if not all the above three options
amt = 90;
cout<<"Officer, is this the driver's 1st offence(answer with y for yes and anything else for no) :";
cin>>offence;
if((offence=='y')||(offence=='Y'))
demerit= 3;
else{
cout<<"Last Question officer! How many demerit points did the driver have prior to being stopped?";
cin>>demerit;
demerit = demerit+3;
}
cout<<"Write a ticket for $"<<amt<<" and inform the driver that they now have "<<demerit<<" demerit points."<<endl;
break;
case 5://to exit
cout<<"Thank you.!!!";
break;
default://if the user enters other values
cout<<"Officer please choose the correct option(1-4). ";
  
}
system("PAUSE");
}while(choice!=5);
return 0;
}

void display_menu(){//function for displaying the menu
cout<<"-----------------------------------------------"<<endl;
cout<<"welcome to the fine and demerit point Evaluvater!"<<endl;
cout<<" based on Crazy Nancy Criteria"<<endl;
cout<<"------------------------------------------------"<<endl;
cout<<"Welcome officer- I need some information before i tell you";
cout<<" what the fine and demerit points are. Here are the possible locations :"<<endl;
cout<<" 1. Driver was stopped on the highway."<<endl;
cout<<" 2. In a School zone."<<endl;
cout<<" 3. Car is stopper at a stop sign or traffic light."<<endl;
cout<<" 4. None of the above."<<endl;
cout<<" 5. Exit."<<endl;

}

Sample Run:

-----------------------------------------------
welcome to the fine and demerit point Evaluvater!
based on Crazy Nancy Criteria
------------------------------------------------
Welcome officer- I need some information before i tell you what the fine and demerit points are.
Here are the possible locations :
1. Driver was stopped on the highway.
2. In a School zone.
3. Car is stopper at a stop sign or traffic light.
4. None of the above.
5. Exit.
Please Enter the digit corresponding to your case :4
Officer, is this the driver's 1st offence(answer with y for yes and anything else for no) :n
Last Question officer! How many demerit points did the driver have prior to being stopped?3
Write a ticket for $90 and inform the driver that they now have 6 demerit points.
Press any key to continue . . .

-----------------------------------------------
welcome to the fine and demerit point Evaluvater!
based on Crazy Nancy Criteria
------------------------------------------------
Welcome officer- I need some information before i tell you what the fine and demerit points are.
Here are the possible locations :
1. Driver was stopped on the highway.
2. In a School zone.
3. Car is stopper at a stop sign or traffic light.
4. None of the above.
5. Exit.
Please Enter the digit corresponding to your case :5
Press any key to continue . . .

Thank you.!!!
RUN SUCCESSFUL (total time: 4m 3s)