convertion input

here is my code :
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
/* 
	File name : looping
	Author : Muhammad Bin Md Yazed
	Date created : 26/10/2012
	Objective(s) : 1) using selection
	  	       2) to make parking ticket machine
*/

#include <iostream>

using namespace std;

int main()
{
	char vehicleType;
	char plateNumber [8]; 
	float totalHour, fees;
	
	cout<< "   #####   WELCOME TO THE AUTO PAY MACHINE   #####"<<endl
	<<endl <<endl;

	cout<< "   A for Motorcycle."<<endl;
	cout<< "   B for Car."<<endl;
	cout<< "   C for Lorry."<<endl <<endl;
	cout<< "   Please enter your vehicle class : ";

	cin>> vehicleType;
	
	cout<< "\n\n   Please enter your plate number : ";
	cin>> plateNumber;

	cout<< "\n\n   Please enter Total Hours : ";
	cin>>totalHour;

	cout<<endl <<endl;

	switch (toupper(vehicleType))
          {
              case 'A' :
                      if (totalHour == 2)
                         {
                          fees=0.50;
                         }
                      else if ((totalHour > 2) && (totalHour <= 6))
                         {
                          fees=(totalHour-2)*0.50+0.50;
                          }
                      else if ((totalHour > 6) && (totalHour <= 12))
                          {
                           fees=(totalHour-6)*1.00+1.50;
                          }
                       else
                          {
                           fees=20; //+7.50
                          }  
			break;

              case 'B' :
                      if (totalHour == 2)
                         {
                          fees=1.00;
                         }
                      else if ((totalHour > 2) && (totalHour <= 6))
                         {
                          fees=(totalHour-2)*1.00+1.00;
                          }
                      else if ((totalHour > 6) && (totalHour <= 12))
                          {
                           fees=(totalHour-6)*1.50+5.00;
                          }
                       else
                          {
                           fees=50; //+14.00
                          }  
			 break;

              case 'C' :
                      if (totalHour == 2)
                         {
                          fees=1.50;
                         }
                      else if ((totalHour > 2) && (totalHour <= 6))
                         {
                          fees=(totalHour-2)*2.00+1.50;
                          }
                      else if ((totalHour > 6) && (totalHour <= 12))
                          {
                           fees=(totalHour-6)*2.50+9.50;
                          }
                       else
                          {
                           fees=100;  //+34.50
			   }  
			 break;

	      default :
		     cout<<"\a\a\a   Your enter wrong vehicle class."
		     <<" Please re-enter your vehicle class."<<endl <<endl;
	}

	cout.setf(ios::fixed, ios::floatfield);
	cout.precision(2);
        cout<<"   "<<"Plate Number : "<<plateNumber
        <<"   Vehicle Class : "<<vehicleType<<"   Your fees"
	<<" is : RM " <<fees <<endl <<endl;


	system ("PAUSE");
	return 0;
}




and the output as follow :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
   #####   WELCOME TO THE AUTO PAY MACHINE   #####


   A for Motorcycle.
   B for Car.
   C for Lorry.

   Please enter your vehicle class : a


   Please enter your plate number : csba4r


   Please enter Total Hours : 7


   Plate Number : csba4r   Vehicle Class : a   Your fees is : RM 2.50

Press any key to continue . . .



my question are :
-how to convert user lower case input vehicleType and plateNumber to upper case?

-why when user enter invalid Vehicle class, no output from default?
Last edited on
All answers in your code:
1)
how to convert user lower case input vehicleType and plateNumber to upper case?

Line 37: toupper(vehicleType)

2)
why when user enter invalid Vehicle class, no output from default?

There is output: http://gm4.in/i/czm.png
Topic archived. No new replies allowed.