Hello. I'm still fairly new with C++.
I started on a code with a friend, but I'm still very unsure about setting up loops and such.
Some help on where to go next with this problem would be much appreciated!
This program requires you to input information about vehicles in a parking lot and calculate their bill for parking. The input for a vehicle will consist of a character and four integer values.
The character will be either C, T, or B; this indicates car, truck, or bus.
The first integer ( 0 <= hr_in < 24) will represent the hour of the arrival time of the vehicle
The second integer ( 0 <= min_in < 60) will represent the minutes of the arrival time of the vehicle
The third integer ( 0 <= hr_out < 24) will represent the hour of the departure time of the vehicle
The fourth integer ( 0 <= min_out < 60) will represent the minutes of the departure time of the vehicle
For example C 10 30 13 0
A car arrived at 10:30 and left at 13:00.
Parking fees are detailed in the table that follows:
Type of vehicle Initial rate Rate for additional time
Car First 3 hours are free
$1.50 per hour after the first 3
Truck First 2 hours cost $2.50
$5.00 per hour after the first 2
Bus First hour costs $5.00 $7.50 per hour after the first
this is what I have so far.....
#include <fstream>
#include <iomanip>
#include <iostream>
using namespace std;
int main()
{
if(a=='C'){
cout<<"What hour did they arrive?"<<endl;
cin>>integar1;
cout<<"What minute did they arrive?"<<endl;
cin>>integar2;
cout<<"What hour did they depart?"<<endl;
cin>>integar3;
cout<<"What minute did they depart?"<<endl;
cin>>integar4;
double arrive = integar1 + (integar2/100);
double depart = integar3 + (integar4/100);
double duration = depart - arrive;
//If statement for first 3 hours
if (duration <= 3.0){
cout<<"****************************"<<endl;
cout<<" Parking Garage Charges "<<endl;
cout<<"****************************"<<endl;
cout<<"No Charge"<<endl;
}
if (duration > 3.0){
double cost = (duration - 3.0) * 1.50;
cout<<"============================"<<endl;
cout<<" Parking Garage Charges "<<endl;
cout<<"============================"<<endl;
cout<<"Arrived at:" << " " << arrive << " " << "Departed" << " " << depart <<endl;
cout<<"Duration" << " " << setprecision(2)<< duration << " " << "hours"<<endl;
cout<<"Cost:" << " " << setprecision(2)<< cost << " " << "dollars"<<endl;
}