So the equation on if type == c are the same as else type == t
however when a user inputs type c and there min the program
still charges for the discount of 2 hours and only displays total hours
at 2 less then it should?
Also as a side not i need the output of type to be the full word
CAR or Truck?
/**********************************************************************
* Program Name :
* Author :
* Date :
* Course/Section : CSC110-1001
* Program Description: This program will determine the total cost
* of parking for cars and trucks. It will do this by taking the
* amount of time each viechle has been parked and multiply that
* by the the cost of parking and subtracting the discount of each
* veichle
*
*
* BEGIN Lab 04 - Calculate the total for park
* Input the vechile type
* Input the minutes parked
* Clear screen
* IF (invlaid vechile type)
* Disply error;
* ELSE
* IF (veichle is a car)
* vechile make = car
* Divided Minutes by sixty minutes
Round number to next whole number
subtract 2 from whole number
Multiply rate by hours
* ELSE
* vechile is a truck
* Divided Minutes by sixty minutes
Round number to next whole number
subtract 1 from whole number
Multiply rate by hours
* END IF
* Calculate hours parked
* Calculate fee
* Display Recipt
* END IF
* END Lab 04 - Calculate the total for park
**********************************************************************/
#include <cmath>
#include <iostream>
#include <iomanip>
usingnamespace std;
void main()
{
// local constants
constchar CAR ='C'; //Vehicale Type
constchar TRUCK ='T'; //Vehicale Type
constfloat RATE_C = 1.75; //Car Fee to park
constfloat RATE_T = 3.00; //Truck Fee to park
constint DISCOUNT_C = 2; //Car Discount
constint DISCOUNT_T = 1; //Truck Discount
constint HOUR = 60; //Sixty Minutes
// local variables
char Type; //Vehicale Type
float Min ; //Minutes Parked
float Park_Fee; //Fee to park
int Hours; //Hours Parked
/*********************************************************************/
//Prompt for number input
cout << "\n\n\n\n\n\n\n";
cout << setw(55) << "--------------------------------" << endl;
cout << setw(55) << " Vehicale Type & Minutes Parked " << endl;
cout << setw(55) << "--------------------------------" << endl;
cout << "\n" << setw (46) << " Vehicale Type: ";
cin >> Type;
cout << "\n" << setw (46) << " Minutes Parked: ";
cin >> Min;
// Clear the screen
system ("cls");
//IF (invlaid vechile type)
if(Type != CAR && Type != TRUCK)
{
// Disply error;
cout << setw(50) << " Invaled type" << endl;
}
else
{
//if (veichle is a car)
if (Type == 'C')
{
//vechile make is car
//Divided Minutes by sixty minutes and round to next whole number
Hours = ceil (Min / HOUR);
//subtract 2 from whole number if needed
Hours = Hours -= DISCOUNT_C;
//Multiply rate by hours
Park_Fee = RATE_C * Hours;
//Add two too get total hours
Hours = Hours + 2;
}
else
{
//Vehical make is truck
//Divided Minutes by sixty minutes round to next whole number
Hours = ceil (Min/HOUR);
//subtract 1 from whole number if needed
Hours = Hours -= DISCOUNT_T;
//Multiply rate by hours
Park_Fee = RATE_T * Hours;
//Add two too get total hours
Hours = Hours + 1;
}
//Output Vehicle type, Hours Parked, and Parking Fee
cout << setiosflags (ios::fixed) << setprecision(2);
cout << "\n\n\n\n\n\n\n";
cout << setw(47) << "----------------" << endl;
cout << setw(45) << " Vehicle Type " << Type << endl;
cout << setw(45) << " Hours Parked " << Hours << endl;
cout << setw(44) << " Parking Fee " << Park_Fee << endl;
cout << setw(47) << "----------------" << endl;
cout << "\n\n\n\n";
}
} // end main program