Project Write a C program to manage a parking lot Build Spec

Project:

Write a C++ program to manage a parking lot.

Build Specifications

1. The parking lot has multiple levels. Each level has multiple rows of spots.

2. The parking lot can park motorcycles, cars, and buses.
3. The parking lot has motorcycle spots, compact spots, and large spots.
4. A motorcycle can park in any spot.

5. A car can park in either a single compact spot or a single large spot.

6. A bus can park in five large spots that are consecutive and within the same row. It cannot park in small spots.

Function description (70 point):

Setup the parking lot. You should be able to create a customizable parking lot.

Edittheparkinglotlayout:Youshouldbeabletochangetheparkinglotlayout.For

example: Add levels, change the spot layout at a level, etc.

Reserve: You need to be able to reserve a spot. The user should provide the level

number, the row number, and then the spot number.

Search: See how many free spots on a specific level.

Get Free spots: How to get how many free spots of each kind in the whole parking lot.

View: View all levels and their information

The program must have the following properties (60 points):

- You should do error handling (Ex: you cannot choose a level that does not exist)

- You should use inheritance, polymorphism, and aggregation. Example: You can design a generic spot class, then design derived classes for different kinds of spots.

- Save and load data from and to a file.

- Give Visual representation to show which spots are occupied. You can show this by level. The output should be a matrix that maybe puts an X in occupied spots.

-Also, design a menu (should still appear until the exit option is chosen) in the Main program that has the following options implemented to test your classes’ functionality (30 points):

1. Setup the parking lot

2. Edit

3. Look for capacity

4. View level information

5. Exit

Solution

#include <iostream>
#include <conio.h>
#include <ctype.h>
using namespace std;

int main()
{
char vehicle;
int hour_in,minute_in,hour_out,minute_out;

/*varible used in Car condition*/
float totalhour,totalminute,inminute,fee,fee2;
int minuteout2,minutein2,totalminute2,hour2cout,minute2cout,hour3cout,minute3cout,prohourin1,prohourout1;

/*varible used in bus condition*/
float minutebus,feebus1,feebus2,feebus2total,feebushour,feedown,busup60,feebusup60;
int minutebusout,minutebusin,totalminutebusup,hourbusup,minutebusup,prohourin2,prohourout2;

/*varible used in truck condition*/
int minutetruck,minutetruckin,minutetruckout,totalminutetruckup,hourtruckup,minutetruckup,prohourin3,prohourout3;
float feetruck1,feetruckhour,feetruck2total,feetruck2,feetruckdown,feetruck60;

/*input Data*/
/*Introduction inputting data*/
cout<<\"\\t\\t\\t\\t\\tCar Park\"<<endl;
cout<<\"\\t\\t\\t\\t\\t________\ \ \"<<endl;
cout<<\"Introduction:\"\" \"\"Please input value follow by below require.\"<<endl<<endl;
cout<<\" \"\"Require:\"<<endl;
cout<<\" \"\"________\"<<endl<<endl;
cout<<\"\\t-Input type of vehicle:\\t\"\"c=car\"\",\"\"t=truck\"\",\"\"b=bus\"<<endl;
cout<<\"\\t\\t\\t\\tData must be in one alphabat and lower case.\"<<endl<<endl;
cout<<\"\\t-Input time\\t :\\t\"\"Must be in digit.\"<<endl;
cout<<\"\\t\\t\\t\\tInput in 24 class time.\"<<endl;
cout<<\"\\t\\t\\t\\tHour is lower or equal 24 hours.\"<<endl;
cout<<\"\\t\\t\\t\\tMinute is lower 60 minutes.\"<<endl;
cout<<\"\\t\\t\\t\\tTime in must be lower than time out.\"<<endl;

cout<<\"Input type of vehicle:\"<<endl;
input:
cin>>vehicle;

if (vehicle==\'c\'){
reinputpro1:
cout<<\"\ Input time in\"<<endl<<endl;
cout<<\"Hour in:\";
hour:

cin>>hour_in;

if((hour_in>24)){
cout<<\"Incorrect input hour in,Please reinput.\"<<endl;
goto hour;}
else if((hour_in<0)){
cout<<\"Input only positive value,Please reinput.\"<<endl;
goto hour;
}

cout<<\"Minute in:\";
minute:
cin>>minute_in;

if((minute_in>59)){
cout<<\"Incorrect input minute in,Please reinput.\"<<endl;
goto minute;}
else if((minute_in<0)){
cout<<\"Input only positive value,Please reinput.\"<<endl;
goto minute;
}

cout<<\"\ Input time out\"<<endl<<endl;
cout<<\"Hour Out:\";
hourout1:
cin>>hour_out;
if((hour_out>24)){
cout<<\"Incorrect input hour out,Please reinput.\"<<endl;
goto hourout1;
}
else if((hour_out<0)){
cout<<\"Input only positive value,Please reinput.\"<<endl;
goto hourout1;
}
cout<<\"Minute out:\";
minuteout:
cin>>minute_out;
if((minute_out>24)){
cout<<\"Incorrect input minute out,Please reinput.\"<<endl;
goto minuteout;
}
else if((minute_out<0)){
cout<<\"Input only positive value,Please reinput.\"<<endl;
goto minuteout;
}
prohourin1=(hour_in*60)+minute_in;
prohourout1=(hour_out*60)+minute_out;
if(prohourin1>prohourout1){
cout<<\"\ The Time out must bigger than Time in, Please reinput.\"<<endl;
goto reinputpro1;
}
/*End input Data*/
if(minute_in<=minute_out){ /*minute-out bigger than minute-in EX:in7:10 out8:12*/
totalhour=hour_out-hour_in;
totalminute=minute_out-minute_in;
inminute=(totalhour*60)+totalminute;

if(inminute<=180){ /*Smaller or equal to 180mn=3hour*/

cout<<\"\\t\\t\\t\\tReport:\"<<endl;
cout<<\"\ ==========================================================================\"<<endl;
cout<<\"Vehicle Type\\t\"\"Time in\\t\\t\"\"Time out\\t\"\"Total Time\\t\"\"Check Out\"<<endl;
cout<<\"Car\\t\\t\"<<hour_in<<\" : \"<<minute_in<<\"\\t\\t\"<<hour_out<<\" : \"<<minute_out<<\"\\t\\t\"<<totalhour<<\" : \"<<totalminute<<\"\\t\\t\"<<\"No payment\"<<endl;
cout<<\"==========================================================================\"<<endl<<endl;
}
if(inminute>180){ /*Greater than to 180mn=3hour*/
fee=(inminute-180)/60;
fee=fee*1;

cout<<\"\\t\\t\\t\\tReport:\"<<endl;
cout<<\"\ ==========================================================================\"<<endl;
cout<<\"Vehicle Type\\t\"\"Time in\\t\\t\"\"Time out\\t\"\"Total Time\\t\"\"Check Out\"<<endl;
cout<<\"Car\\t\\t\"<<hour_in<<\" : \"<<minute_in<<\"\\t\\t\"<<hour_out<<\" : \"<<minute_out<<\"\\t\\t\"<<totalhour<<\" : \"<<totalminute<<\"\\t\\t\"<<\"$\"<<fee<<endl;
cout<<\"==========================================================================\"<<endl<<endl;
}
}
if(minute_in>minute_out){ /*minute-out smaller than minute-in EX:in7:15 out8:10*/
minutein2=(hour_in*60)+minute_in;
minuteout2=(hour_out*60)+minute_out;
totalminute2=minuteout2-minutein2;
hour2cout=totalminute2/60;
minute2cout=totalminute2%60;

if(totalminute2<=180){ /*Smaller or equal to 180mn=3hour*/

cout<<\"\\t\\t\\t\\tReport:\"<<endl;
cout<<\"\ ==========================================================================\"<<endl;
cout<<\"Vehicle Type\\t\"\"Time in\\t\\t\"\"Time out\\t\"\"Total Time\\t\"\"Check Out\"<<endl;
cout<<\"Car\\t\\t\"<<hour_in<<\" : \"<<minute_in<<\"\\t\\t\"<<hour_out<<\" : \"<<minute_out<<\"\\t\\t\"<<hour2cout<<\":\"<<minute2cout<<\"\\t\\t\"<<\"No payment\"<<endl;
cout<<\"==========================================================================\"<<endl<<endl;
}
if(totalminute2>180){ /*Greater than to 180mn=3hour*/
fee2=float(totalminute2-180)/60;
fee2=fee2*1;
hour3cout=totalminute2/60;
minute3cout=totalminute2%60;

cout<<\"\\t\\t\\t\\tReport:\"<<endl;
cout<<\"\ ==========================================================================\"<<endl;
cout<<\"Vehicle Type\\t\"\"Time in\\t\\t\"\"Time out\\t\"\"Total Time\\t\"\"Check Out\"<<endl;
cout<<\"Car\\t\\t\"<<hour_in<<\" : \"<<minute_in<<\"\\t\\t\"<<hour_out<<\" : \"<<minute_out<<\"\\t\\t\"<<hour3cout<<\" : \"<<minute3cout<<\"\\t\\t\"<<\"$\"<<fee2<<endl;
cout<<\"==========================================================================\"<<endl<<endl;
}
}
}
/*End Car condition*/

else if(vehicle==\'b\'){
reinputpro2:
cout<<\"\ Input time in\"<<endl<<endl;
cout<<\"Hour in:\";
hour2:
cin>>hour_in;

if((hour_in>24)){
cout<<\"Incorrect input hour in,Please reinput.\"<<endl;
goto hour2;
}
else if((hour_in<0)){
cout<<\"Input only positive value,Please reinput.\"<<endl;
goto hour2;
}
cout<<\"Minute in:\";
minute2:
cin>>minute_in;

if((minute_in>59)){
cout<<\"Incorrect input minute in,Please reput.\"<<endl;
goto minute2;}
else if((minute_in<0)){
cout<<\"Input only positive value,Please reinput.\"<<endl;
goto minute2;
}

cout<<\"\ Input time out\"<<endl<<endl;

cout<<\"Hour Out:\";
hour2outbus:
cin>>hour_out;
if((hour_out>24)){
cout<<\"Incorrect input hour out,Please reinput.\"<<endl;
goto hour2outbus;
}
else if((hour_out<0)){
cout<<\"Input only positive value,Please reinput.\"<<endl;
goto hour2outbus;
}
cout<<\"Minute out:\";
minute2outbus:
cin>>minute_out;

if((minute_out>59)){
cout<<\"Input only positive value,Please reput.\"<<endl;
goto minute2outbus;}
else if((minute_out<0)){
cout<<\"Incorrect input hour in,Please reinput.\"<<endl;
goto minute2outbus;
}
prohourin2=(hour_in*60)+minute_in;
prohourout2=(hour_out*60)+minute_out;
if(prohourin2>prohourout2){
cout<<\"\ The Time out must bigger than Time in, Please reinput.\"<<endl;
goto reinputpro2;}
/*End input Data*/
if(minute_in<=minute_out){ /*minute-out bigger than minute-in EX:in7:10 out8:12*/
totalhour=hour_out-hour_in;
totalminute=minute_out-minute_in;
minutebus=(totalhour*60)+totalminute;
feebus1=(minutebus/60)*2; //$2 per hour

if(minutebus<=60){ /*Smaller or equal to 60mn=1hour*/

cout<<\"\\t\\t\\t\\tReport:\"<<endl;
cout<<\"\ ==========================================================================\"<<endl;
cout<<\"Vehicle Type\\t\"\"Time in\\t\\t\"\"Time out\\t\"\"Total Time\\t\"\"Check Out\"<<endl;
cout<<\"Bus\\t\\t\"<<hour_in<<\" : \"<<minute_in<<\"\\t\\t\"<<hour_out<<\" : \"<<minute_out<<\"\\t\\t\"<<totalhour<<\" : \"<<totalminute<<\"\\t\\t\"<<\"$\"<<feebus1<<endl;
cout<<\"==========================================================================\"<<endl<<endl;
}
if(minutebus>60){ /*Greater than to 60mn=1hour*/
feebushour=(minutebus-60)/60;
feebus2total=feebushour*5; //$5 per hour
feebus2=2+feebus2total; //$2+$5 per hour

cout<<\"\\t\\t\\t\\tReport:\"<<endl;
cout<<\"\ ==========================================================================\"<<endl;
cout<<\"Vehicle Type\\t\"\"Time in\\t\\t\"\"Time out\\t\"\"Total Time\\t\"\"Check Out\"<<endl;
cout<<\"Bus\\t\\t\"<<hour_in<<\" : \"<<minute_in<<\"\\t\\t\"<<hour_out<<\" : \"<<minute_out<<\"\\t\\t\"<<totalhour<<\" : \"<<totalminute<<\"\\t\\t\"<<\"$\"<<feebus2<<endl;
cout<<\"==========================================================================\"<<endl<<endl;
}
}
if(minute_in>minute_out){ /*minute-out smaller than minute-in EX:in7:15 out8:10*/
minutebusin=(hour_in*60)+minute_in;
minutebusout=(hour_out*60)+minute_out;
totalminutebusup=minutebusout-minutebusin;
hourbusup=totalminutebusup/60;
minutebusup=totalminutebusup%60;
feedown=float(totalminutebusup)/60;
feedown=feedown*2; //$2 perhour

if(totalminutebusup<=60){ /*Smaller or equal to 60mn=1hour*/

cout<<\"\\t\\t\\t\\tReport:\"<<endl;
cout<<\"\ ==========================================================================\"<<endl;
cout<<\"Vehicle Type\\t\"\"Time in\\t\\t\"\"Time out\\t\"\"Total Time\\t\"\"Check Out\"<<endl;
cout<<\"Bus\\t\\t\"<<hour_in<<\" : \"<<minute_in<<\"\\t\\t\"<<hour_out<<\" : \"<<minute_out<<\"\\t\\t\"<<hourbusup<<\":\"<<minutebusup<<\"\\t\\t\"<<\"$\"<<feedown<<endl;
cout<<\"==========================================================================\"<<endl<<endl;
}
if(totalminutebusup>60){ /*Greater than to 60mn=1hour*/
busup60=float(totalminutebusup-60)/60;
feebusup60=2+(busup60*5);

cout<<\"\\t\\t\\t\\tReport:\"<<endl;
cout<<\"\ ==========================================================================\"<<endl;
cout<<\"Vehicle Type\\t\"\"Time in\\t\\t\"\"Time out\\t\"\"Total Time\\t\"\"Check Out\"<<endl;
cout<<\"Bus\\t\\t\"<<hour_in<<\" : \"<<minute_in<<\"\\t\\t\"<<hour_out<<\" : \"<<minute_out<<\"\\t\\t\"<<hourbusup<<\":\"<<minutebusup<<\"\\t\\t\"<<\"$\"<<feebusup60<<endl;
cout<<\"==========================================================================\"<<endl<<endl;
}
}

}
/*End Bus condition*/

else if(vehicle==\'t\'){
reinputpro3:
cout<<\"\ Input time in\"<<endl<<endl;
cout<<\"Hour in:\";
hour3:
cin>>hour_in;

if((hour_in>24)){
cout<<\"Incorrect input hour in,Please reinput.\"<<endl;
goto hour3;
}
else if((hour_in<0)){
cout<<\"Input only positive value,Please reinput.\"<<endl;
goto hour3;
}
cout<<\"Minute in:\";
minute3:
cin>>minute_in;

if((minute_in>59)){
cout<<\"Incorrect input minute in,Please reinput.\"<<endl;
goto minute3;}
else if((minute_in<0)){
cout<<\"Input only positive value,Please reinput.\"<<endl;
goto minute3;
}

cout<<\"\ Input time out\"<<endl<<endl;
cout<<\"Hour Out:\";
hourouttruck:
cin>>hour_out;
if((hour_out>24)){
cout<<\"Incorrect input hour out,Please reinput.\"<<endl;
goto hourouttruck;
}
else if((hour_out<0)){
cout<<\"Input only positive value,Please reinput.\"<<endl;
goto hourouttruck;
}
cout<<\"Minute out:\";
minuteouttruck:
cin>>minute_out;
if((minute_out>59)){
cout<<\"Incorrect input minute out,Please reinput.\"<<endl;
goto minuteouttruck;}
else if((minute_out<0)){
cout<<\"Input only positive value,Please reinput.\"<<endl;
goto minuteouttruck;
}
prohourin3=(hour_in*60)+minute_in;
prohourout3=(hour_out*60)+minute_out;
if(prohourin3>prohourout3){
cout<<\"\ The Time out must bigger than Time in, Please reinput.\"<<endl;
goto reinputpro3;}
/*End input Data*/
if(minute_in<=minute_out){ /*minute-out bigger than minute-in EX:in7:10 out8:12*/
totalhour=hour_out-hour_in;
totalminute=minute_out-minute_in;
minutetruck=(totalhour*60)+totalminute;

if(minutetruck<=120){ /*Smaller or equal to 120mn=2hour*/
feetruck1=(float(minutetruck)/60)*1.5; //$1.5 per hour

cout<<\"\\t\\t\\t\\tReport:\"<<endl;
cout<<\"\ ==========================================================================\"<<endl;
cout<<\"Vehicle Type\\t\"\"Time in\\t\\t\"\"Time out\\t\"\"Total Time\\t\"\"Check Out\"<<endl;
cout<<\"Truck\\t\\t\"<<hour_in<<\" : \"<<minute_in<<\"\\t\\t\"<<hour_out<<\" : \"<<minute_out<<\"\\t\\t\"<<totalhour<<\" : \"<<totalminute<<\"\\t\\t\"<<\"$\"<<feetruck1<<endl;
cout<<\"==========================================================================\"<<endl<<endl;
}
if(minutetruck>120){ /*Greater than to 120mn=2hour*/
feetruckhour=(float(minutetruck)-120)/60;
feetruck2total=feetruckhour*3.5; //$3.5 per hour
feetruck2=3+feetruck2total; //$3 = $1.5 * 2 hours //$3+$3.5 per hour

cout<<\"\\t\\t\\t\\tReport:\"<<endl;
cout<<\"\ ==========================================================================\"<<endl;
cout<<\"Vehicle Type\\t\"\"Time in\\t\\t\"\"Time out\\t\"\"Total Time\\t\"\"Check Out\"<<endl;
cout<<\"Truck\\t\\t\"<<hour_in<<\" : \"<<minute_in<<\"\\t\\t\"<<hour_out<<\" : \"<<minute_out<<\"\\t\\t\"<<totalhour<<\" : \"<<totalminute<<\"\\t\\t\"<<\"$\"<<feetruck2<<endl;
cout<<\"==========================================================================\"<<endl<<endl;
}
}
if(minute_in>minute_out){ /*minute-out smaller than minute-in EX:in7:15 out8:10*/
minutetruckin=(hour_in*60)+minute_in;
minutetruckout=(hour_out*60)+minute_out;
totalminutetruckup=minutetruckout-minutetruckin;
hourtruckup=totalminutetruckup/60;
minutetruckup=totalminutetruckup%60;
feetruckdown=float(totalminutetruckup)/60;

if(totalminutetruckup<=120){ /*Smaller or equal to 120mn=2hour*/
feetruckdown=feetruckdown*1.5; //$1.5 per hour

cout<<\"\\t\\t\\t\\tReport:\"<<endl;
cout<<\"\ ==========================================================================\"<<endl;
cout<<\"Vehicle Type\\t\"\"Time in\\t\\t\"\"Time out\\t\"\"Total Time\\t\"\"Check Out\"<<endl;
cout<<\"Truck\\t\\t\"<<hour_in<<\" : \"<<minute_in<<\"\\t\\t\"<<hour_out<<\" : \"<<minute_out<<\"\\t\\t\"<<hourtruckup<<\":\"<<minutetruckup<<\"\\t\\t\"<<\"$\"<<feetruckdown<<endl;
cout<<\"==========================================================================\"<<endl<<endl;
}
if(totalminutetruckup>120){ /*Greater than to 120mn=2hour*/
feetruck60=(float(totalminutetruckup)-120)/60;
feetruck60=3+(feetruck60*3.5); //$3 = $1.5 * 2 hours //$3+$3.5 per hour

cout<<\"\\t\\t\\t\\tReport:\"<<endl;
cout<<\"\ ==========================================================================\"<<endl;
cout<<\"Vehicle Type\\t\"\"Time in\\t\\t\"\"Time out\\t\"\"Total Time\\t\"\"Check Out\"<<endl;
cout<<\"Truck\\t\\t\"<<hour_in<<\" : \"<<minute_in<<\"\\t\\t\"<<hour_out<<\" : \"<<minute_out<<\"\\t\\t\"<<hourtruckup<<\":\"<<minutetruckup<<\"\\t\\t\"<<\"$\"<<feetruck60<<endl;
cout<<\"==========================================================================\"<<endl<<endl;
}
}
}
/*End Truck condition*/

else{

cout<<\"There is no type of vechicle you input or incorrect input,Please reinput...\"<<endl;
goto input;
}
getch();
return 0;
}

Project: Write a C++ program to manage a parking lot. Build Specifications 1. The parking lot has multiple levels. Each level has multiple rows of spots. 2. The
Project: Write a C++ program to manage a parking lot. Build Specifications 1. The parking lot has multiple levels. Each level has multiple rows of spots. 2. The
Project: Write a C++ program to manage a parking lot. Build Specifications 1. The parking lot has multiple levels. Each level has multiple rows of spots. 2. The
Project: Write a C++ program to manage a parking lot. Build Specifications 1. The parking lot has multiple levels. Each level has multiple rows of spots. 2. The
Project: Write a C++ program to manage a parking lot. Build Specifications 1. The parking lot has multiple levels. Each level has multiple rows of spots. 2. The
Project: Write a C++ program to manage a parking lot. Build Specifications 1. The parking lot has multiple levels. Each level has multiple rows of spots. 2. The
Project: Write a C++ program to manage a parking lot. Build Specifications 1. The parking lot has multiple levels. Each level has multiple rows of spots. 2. The
Project: Write a C++ program to manage a parking lot. Build Specifications 1. The parking lot has multiple levels. Each level has multiple rows of spots. 2. The

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site