0% found this document useful (0 votes)
4 views

C++ Assignment 2

I don’t have a lot but I can try to find it if I need to get some more money from you and I’ll get you something else to drink and then you can go home and eat something to drink so I don’t think I can do that I have to get a drink or whatever you can do that would make me happy to do it but I just need to know how much I have to get out

Uploaded by

muhyideenmisbah
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

C++ Assignment 2

I don’t have a lot but I can try to find it if I need to get some more money from you and I’ll get you something else to drink and then you can go home and eat something to drink so I don’t think I can do that I have to get a drink or whatever you can do that would make me happy to do it but I just need to know how much I have to get out

Uploaded by

muhyideenmisbah
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

#include <iostream>

#include <math.h>
using namespace std;
int main() {
char type;
int hr_in,min_in,hr_out,min_out,cardiff_1,cardiff_2;
double cartime;

cout<<"Enter type please: ";


cin>>type;

switch (type){
case 'c':
cout<<"Enter time in: ";
cin>>hr_in;
cout<<":";
cin>>min_in;
cout<<"Enter time out: ";
cin>>hr_out;
cout<<":";
cin>>min_out;
if(hr_in <= 24 || hr_out <=24){
cardiff_1=hr_out-hr_in;
cardiff_2=min_out-min_in;
if(cardiff_1 <= 3){
cartime=cardiff_1*0.00;
cout<<"\n\t\tPARKING LOT CHARGE\t\t\n";
cout<<"Type of vehicle: Car\n";
cout<<"TME – IN "<< hr_in<< ":" << min_in<<endl;
cout<<"TME – OUT "<< hr_out<< ":" << min_out<<endl;
cout<<"\t\t_______________________\n";
cout<<"PARKING TIME "<< cardiff_1<< ":" <<
abs(cardiff_2)<<endl;
cout<<"ROUNDED TOTAL "<<round(cartime)<<endl;
cout<<"\t\t_______________________\n";
cout<<"TOTAL CHARGE $"<<cartime<<endl;
}
else if(cardiff_1 > 3){
cartime=cardiff_1*1.50;
cout<<"\n\t\tPARKING LOT CHARGE\t\t\n";
cout<<"Type of vehicle: Car\n";
cout<<"TME – IN "<< hr_in<< ":" << min_in<<endl;
cout<<"TME – OUT "<< hr_out<< ":" << min_out<<endl;
cout<<"\t\t_______________________\n";
cout<<"PARKING TIME "<< cardiff_1<< ":" <<
abs(cardiff_2)<<endl;
cout<<"ROUNDED TOTAL "<<round(cartime)<<endl;
cout<<"\t\t_______________________\n";
cout<<"TOTAL CHARGE $"<<cartime<<endl;
}
}
else{
cout<<"Error: hour in or hour out is incorrect!!! Must be in
24hr format!";
}

break;
case 'C':
cout<<"Enter time in: ";
cin>>hr_in;
cout<<":";
cin>>min_in;
cout<<"Enter time out: ";
cin>>hr_out;
cout<<":";
cin>>min_out;
if(hr_in <= 24 || hr_out <=24){
cardiff_1=hr_out-hr_in;
cardiff_2=min_out-min_in;
if(cardiff_1 <= 3){
cartime=cardiff_1*0.00;
cout<<"\n\t\tPARKING LOT CHARGE\t\t\n";
cout<<"Type of vehicle: Car\n";
cout<<"TME – IN "<< hr_in<< ":" << min_in<<endl;
cout<<"TME – OUT "<< hr_out<< ":" << min_out<<endl;
cout<<"\t\t_______________________\n";
cout<<"PARKING TIME "<< cardiff_1<< ":" <<
abs(cardiff_2)<<endl;
cout<<"ROUNDED TOTAL "<<round(cartime)<<endl;
cout<<"\t\t_______________________\n";
cout<<"TOTAL CHARGE $"<<cartime<<endl;
}
else if(cardiff_1 > 3){
cartime=cardiff_1*1.50;
cout<<"\n\t\tPARKING LOT CHARGE\t\t\n";
cout<<"Type of vehicle: Car\n";
cout<<"TME – IN "<< hr_in<< ":" << min_in<<endl;
cout<<"TME – OUT "<< hr_out<< ":" << min_out<<endl;
cout<<"\t\t_______________________\n";
cout<<"PARKING TIME "<< cardiff_1<< ":" <<
abs(cardiff_2)<<endl;
cout<<"ROUNDED TOTAL "<<round(cartime)<<endl;
cout<<"\t\t_______________________\n";
cout<<"TOTAL CHARGE $"<<cartime<<endl;
}
}
else{
cout<<"Error: hour in or hour out is incorrect!!! Must be in
24hr format!";
}
case 'b':
cout<<"Enter time in: ";
cin>>hr_in;
cout<<":";
cin>>min_in;
cout<<"Enter time out: ";
cin>>hr_out;
cout<<":";
cin>>min_out;
if(hr_in <= 24 || hr_out <=24){
cardiff_1=hr_out-hr_in;
cardiff_2=min_out-min_in;
if(cardiff_1 <= 2){
cartime=cardiff_1*1.00;
cout<<"\n\t\tPARKING LOT CHARGE\t\t\n";
cout<<"Type of vehicle: Bus\n";
cout<<"TME – IN "<< hr_in<< ":" << min_in<<endl;
cout<<"TME – OUT "<< hr_out<< ":" << min_out<<endl;
cout<<"\t\t_______________________\n";
cout<<"PARKING TIME "<< cardiff_1<< ":" <<
abs(cardiff_2)<<endl;
cout<<"ROUNDED TOTAL "<<round(cartime)<<endl;
cout<<"\t\t_______________________\n";
cout<<"TOTAL CHARGE $"<<cartime<<endl;
}
else if(cardiff_1 > 2){
cartime=cardiff_1*2.30;
cout<<"\n\t\tPARKING LOT CHARGE\t\t\n";
cout<<"Type of vehicle: Bus\n";
cout<<"TME – IN "<< hr_in<< ":" << min_in<<endl;
cout<<"TME – OUT "<< hr_out<< ":" << min_out<<endl;
cout<<"\t\t_______________________\n";
cout<<"PARKING TIME "<< cardiff_1<< ":" <<
abs(cardiff_2)<<endl;
cout<<"ROUNDED TOTAL "<<round(cartime)<<endl;
cout<<"\t\t_______________________\n";
cout<<"TOTAL CHARGE $"<<cartime<<endl;
}
}
else{
cout<<"Error: hour in or hour out is incorrect!!! Must be in
24hr format!";
}
break;
case 'B':
cout<<"Enter time in: ";
cin>>hr_in;
cout<<":";
cin>>min_in;
cout<<"Enter time out: ";
cin>>hr_out;
cout<<":";
cin>>min_out;
if(hr_in <= 24 || hr_out <=24){
cardiff_1=hr_out-hr_in;
cardiff_2=min_out-min_in;
if(cardiff_1 <= 2){
cartime=cardiff_1*1.00;
cout<<"\n\t\tPARKING LOT CHARGE\t\t\n";
cout<<"Type of vehicle: Bus\n";
cout<<"TME – IN "<< hr_in<< ":" << min_in<<endl;
cout<<"TME – OUT "<< hr_out<< ":" << min_out<<endl;
cout<<"\t\t_______________________\n";
cout<<"PARKING TIME "<< cardiff_1<< ":" <<
abs(cardiff_2)<<endl;
cout<<"ROUNDED TOTAL "<<round(cartime)<<endl;
cout<<"\t\t_______________________\n";
cout<<"TOTAL CHARGE $"<<cartime<<endl;
}
else if(cardiff_1 > 2){
cartime=cardiff_1*2.30;
cout<<"\n\t\tPARKING LOT CHARGE\t\t\n";
cout<<"Type of vehicle: Bus\n";
cout<<"TME – IN "<< hr_in<< ":" << min_in<<endl;
cout<<"TME – OUT "<< hr_out<< ":" << min_out<<endl;
cout<<"\t\t_______________________\n";
cout<<"PARKING TIME "<< cardiff_1<< ":" <<
abs(cardiff_2)<<endl;
cout<<"ROUNDED TOTAL "<<round(cartime)<<endl;
cout<<"\t\t_______________________\n";
cout<<"TOTAL CHARGE $"<<cartime<<endl;
}
}
else{
cout<<"Error: hour in or hour out is incorrect!!! Must be in
24hr format!";
}
break;
case 't':
cout<<"Enter time in: ";
cin>>hr_in;
cout<<":";
cin>>min_in;
cout<<"Enter time out: ";
cin>>hr_out;
cout<<":";
cin>>min_out;
if(hr_in <= 24 || hr_out <=24){
cardiff_1=hr_out-hr_in;
cardiff_2=min_out-min_in;
if(cardiff_1 == 1){
cartime=cardiff_1*2.00;
cout<<"\n\t\tPARKING LOT CHARGE\t\t\n";
cout<<"Type of vehicle: Truck\n";
cout<<"TME – IN "<< hr_in<< ":" << min_in<<endl;
cout<<"TME – OUT "<< hr_out<< ":" << min_out<<endl;
cout<<"\t\t_______________________\n";
cout<<"PARKING TIME "<< cardiff_1<< ":" <<
abs(cardiff_2)<<endl;
cout<<"ROUNDED TOTAL "<<round(cartime)<<endl;
cout<<"\t\t_______________________\n";
cout<<"TOTAL CHARGE $"<<cartime<<endl;
}
else if(cardiff_1 > 1){
cartime=cardiff_1*3.70;
cout<<"\n\t\tPARKING LOT CHARGE\t\t\n";
cout<<"Type of vehicle: Truck\n";
cout<<"TME – IN "<< hr_in<< ":" << min_in<<endl;
cout<<"TME – OUT "<< hr_out<< ":" << min_out<<endl;
cout<<"\t\t_______________________\n";
cout<<"PARKING TIME "<< cardiff_1<< ":" <<
abs(cardiff_2)<<endl;
cout<<"ROUNDED TOTAL "<<round(cartime)<<endl;
cout<<"\t\t_______________________\n";
cout<<"TOTAL CHARGE $"<<cartime<<endl;
}
}
else{
cout<<"Error: hour in or hour out is incorrect!!! Must be in
24hr format!";
}
break;
case 'T':
cout<<"Enter time in: ";
cin>>hr_in;
cout<<":";
cin>>min_in;
cout<<"Enter time out: ";
cin>>hr_out;
cout<<":";
cin>>min_out;
if(hr_in <= 24 || hr_out <=24){
cardiff_1=hr_out-hr_in;
cardiff_2=min_out-min_in;
if(cardiff_1 == 1 ){
cartime=cardiff_1*2.00;
cout<<"\n\t\tPARKING LOT CHARGE\t\t\n";
cout<<"Type of vehicle: Truck\n";
cout<<"TME – IN "<< hr_in<< ":" << min_in<<endl;
cout<<"TME – OUT "<< hr_out<< ":" << min_out<<endl;
cout<<"\t\t_______________________\n";
cout<<"PARKING TIME "<< cardiff_1<< ":" <<
abs(cardiff_2)<<endl;
cout<<"ROUNDED TOTAL "<<round(cartime)<<endl;
cout<<"\t\t_______________________\n";
cout<<"TOTAL CHARGE $"<<cartime<<endl;
}
else if(cardiff_1 > 1){
cartime=cardiff_1*3.70;
cout<<"\n\t\tPARKING LOT CHARGE\t\t\n";
cout<<"Type of vehicle: Truck\n";
cout<<"TME – IN "<< hr_in<< ":" << min_in<<endl;
cout<<"TME – OUT "<< hr_out<< ":" << min_out<<endl;
cout<<"\t\t_______________________\n";
cout<<"PARKING TIME "<< cardiff_1<< ":" <<
abs(cardiff_2)<<endl;
cout<<"ROUNDED TOTAL "<<round(cartime)<<endl;
cout<<"\t\t_______________________\n";
cout<<"TOTAL CHARGE $"<<cartime<<endl;
}
}
else{
cout<<"Error: hour in or hour out is incorrect!!! Must be in
24hr format!";
}
break;
default:
cout<<"The input is not correct please!!!";
break;
}

return 0;
}

You might also like