Half works same other half doesn't?

Thank you for looking.

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?

Thanks again for the input.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/**********************************************************************
* 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>
using namespace std;

void main()
{
	// local constants 
	const char   CAR        ='C';	//Vehicale Type
	const char   TRUCK      ='T';	//Vehicale Type
	const float  RATE_C     = 1.75; //Car Fee to park
	const float  RATE_T     = 3.00; //Truck Fee to park
	const int    DISCOUNT_C = 2;	//Car Discount
	const int    DISCOUNT_T = 1;	//Truck Discount
	const int	 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 
Topic archived. No new replies allowed.