Help with parking garage program?

Can anyone tell me what is wrong with this code?

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: Damian Roberts April 2018
#include <iostream>
#include "stdafx.h"
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;

int main(void)
{
getInfo(&vehicle, &hourIn, &minIn, &hourOut, &minOut);
time(hourIn, minIn, hourOut, minOut, &hourParkTime, &minParkTime, &roundedTotal, &round);
rate(vehicle, &units, &firstRate, &secondRate);
charge(roundedTotal, units, firstRate, secondRate, &totalCharge);
printBill(vehicle, hourIn, minIn, hourOut, minOut, hourParkTime, minParkTime, roundedTotal, totalCharge);
return 0;
}//end of main.

//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.";

return;
}
//Function definition for charge.
void charge(int roundedTotal, int units, float firtsRate, float secondRate, float totalCharges)
if(roundedTotal <= units)
{
totalCharge = (roundedTotal * firstRate);
}
else
{
totalCharge = (roundedTotal - units) * (secondRate) + (units * firstRate);

return;
}

//Function definition for print Bill.
void printBill(char vehicle, int hourIn, int minIn, int hourOut, int minOut, int hourParkTime, int minParkTime, int roundedTotal, float totalCharge)
{
cout << "Vehicle Type:/t/t"<< vehicle <<endl;
cout << "Time In:/t/t" <<hourIn<<":"<<minIn <<endl;
cout << "Time Out:/t/t" <<hourOut<<":"<<minOut <<endl;
cout << "Total Park Time:/t/t" <<roundedTotal <<endl;
cout << "Total Charge:/t/t" <<totalCharge<<endl;
return;
}
i cant get this to work for the life of me
1) Please use code tags when posting code to make it readable:

http://www.cplusplus.com/articles/z13hAqkS/

2) Why do you think something is wrong. What does "can't get it to work" mean?

How can we possibly know how to help you, if you don't share information with us?
Topic archived. No new replies allowed.