SIDE NOTE: PLEASE USE C++, thank you in advanced
#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<<"\nHow 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<<"\nOfficer, 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).\n";
}
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<<"\tbased 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.\nHere are the
possible locations :"<<endl;
cout<<"\t1. Driver was stopped on the
highway."<<endl;
cout<<"\t2. In a School zone."<<endl;
cout<<"\t3. Car is stopper at a stop sign or traffic
light."<<endl;
cout<<"\t4. None of the above."<<endl;
cout<<"\t5. 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)
SIDE NOTE: PLEASE USE C++, thank you in advanced uestion 1 - Nested selection statements (if/else-switch...
i really need help with the graphs Driving Can Be Dangerous to Your Health: An Interrupted Case Study in Physiology Phil Stephens Department of Biology Villanova University Part 1-The Grandparents Arrive Dave pulled the cell phone out of his pocket, cursing himself for not putting it on vibrate. The children, Jason and Laura, were both asleep, and he knew that the rest of the day would not be fun if they were awakened from their naps. "Hi, Dave. We're just...