Design and develop a program for Parking-Garage charges. A parking garage uses the following rate for the cars, truck, and bus:
CAR
First 3 hours 0.00 after three hour 1.25 per hour
Trucks- first hour 3.75. after 1 hour 4.50 per hour
Buses- first two hours $2.00. after first two hours 2.50 per hour
NO OVER NIGHT PARKING.
The program should not accept time that has HH less than 0 or greater than 23, and MM less than zero and greater than 59. Number of minutes should be only accepted as a positive number. Only valid vehicle type “C”, “T”, or “B” should be accepted.
If the total_minutes_parked is greater than 0, then you should round the total_hours_parked to the next hour (add one to it.) YOU MUST USE “FUCTION” calls, “if/else” control structures, and “switch” structures.
//This program calculates charges for a parking garage based on the type of
//vehicle and the time spent in the garage.
//Author: Tonia Clark November 2011.
#include <iostream>
using namespace std;
//constants for rates
#define firstCarRate 0.00 //first rate for cars.
#define secondCarRate 1.25 //second rate for cars.
#define firstTruckRate 3.75 //first rate for trucks.
#define secondTruckRate 4.50 //second rate for trucks.
#define firstBusRate 2.00 //first rate for buses.
#define secondBusRate 2.50 //second rate for buses.
//getInfo Function Prototype.
void getInfo(char *vehicle, int *hourIn, int *minIn, int *hourOut, int *minOut);
//time function prototype.
void time(int hourIn, int minIn, int hourOut, int minOut, int *houtParkTime, int * minParkTime, int *roundedTotal, int *round);
//rate function prototype.
void rate(char vehicle, int *units, float *firstRate, float *secondRate);
//charge function prototype.
void charge(int roundedTotal, int units, float firstRate, float secondRate, float *totalCharge);
//print bill function prototype.
void printBill (char vehicle, int hourIn, int minIn, int hourOut, int minOut, int hourParkTime, int minParkTime, int roundedTotal, float totalCharge);
//global variables
char vehicle;
int units;
int hourIn;
int minIn;
int hourOut;
int minOut;
int hourParkTime;
int minParkTime;
int roundedTotal;
int round;
float firstRate;
float secondRate;
float totalCharge;
//function definition for get info.
void getInfo(char *vehicle, int *hourIn, int minIn, int *hourOut, int *minOut)
{
cout << "\nType of vehicle? ";
cout << "\n(enter C for car,T for truck or B for bus).";
cin >> vehicle;
//check for valid vehicle type
{
switch(*vehicle)
{
{
case 'C': cout << "You entered C.\n";
case 'c': cout << "You entered c.\n";
break;
case 'T': cout << "You entered T.\n";
case 't': cout << "You entered t.\n";
break;
case 'B': cout << "You entered B.\n";
case 'b': cout << "You entered b.\n";
break;
default: cout << "You did not enter a valid vehicle type\n";
cout << "Please Enter C,c,T,t,B, or b\n";
return;
}
//get the hour that the vehicle entered the garage.
cout << "\nHour vehicle entered garage? ";
cin >> *hourIn;
//validate input for hourIn
if(*hourIn < 0 || *hourIn < 23)
{
cout << "invalid input. enter an integer between 0 and 23.";
}
//get the minute that the vehicle entered the garage.
cout << "\nMinute vehicle entered garage? ";
cin >> minIn;
//validate input for minIn.
if(minIn < 0 || minIn > 60)
{
cout << "invalid input. enter a number between 0 and 60.";
}
//get the hour vehicle exits garage.
cout <<"\nHour vehicle exits garage? ";
cin >> *hourOut;
//validate input for hourOut.
if(*hourOut < 0 || *hourOut < 23)
{
cout << "invalid input. enter an integer between 0 and 23.";
}
//get the minute vehicle exits garage.
cout << "\nMinute vehicle exits garage?";
cin >> *minOut;
//validate input for minOut.
if(minOut < 0 || *minOut > 60)
{
cout << "invalid input. enter a number between 0 and 60.";
return;
}
}
//function definition for time.
void time(int hourIn, int minIn, int hourOut, int minOut, int *hourParkTime, int *minParkime, int *roundedTotal, int *rounded)
{
if (*minOut < minIn)
{
minOut = minOut + 60;
hourOut = hourOut - 1;
}
else
{
hourParkTime = hourOut - hourIn;
minParkTime = *minOut - minIn;
}
if(minParkTime >= 1)
{
round = hourParkTime + 1;
}
else
{
round = hourParkTime;
}
roundedTotal = round;
return;
}
//Function definition for rate.
void rate(char vehicle, int *units, float *firstRate, float *secondRate)
{
switch(*vehicle)
{
{
case 'c':
case 'C': units = 3;
firstRate = firstCarRate;
break;
}
{
case 't':
case 'T': units = 1;
firstRate = firstTruckRate;
secondRate = secondTruckRate;
break;
}
case 'b':
case 'B': units = 2;
firstRate = firstBusRate;
secondRate = secondBusRate;
break;
{
default:
cout << "\nEnter a valid vehicle type.";
You've screwed up the braces. This is probably because you didn't lay out your code in a sensible way using indentation, so you have trouble knowing how many { and } you have used. You have 22 of { but only 18 }.
You are definitely missing at least one } before this line, because this is the point at which the compiler can no longer muddle through. //function definition for time.