Help with program

Please help with my program.
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
  #include "StdAfx.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;


int main()
{
    int hours, minutes;
    string time;
    string hourstr, minutestr; 
    do
    {
        
        cout << " Please input the hour in 24 hour format "<< endl;
        cin >> hourstr;
        cout << " Please input the minutes" << endl;
        cin >>  minutestr; 
        string resulthours;
        string resultminutes;

      if (hours == 12 && minutes == 00)
      {
          cout << "Noon" << endl;
          return 0;
          
      }
      else if (hourstr == 00 && minutestr == 00) 
       {  
            cout << "Midnight" << endl;
            return 0;
      }
      
      switch (hourstr)
      {
        case (1): 
            resulthours = "one";
            break;
        case (2):
            resulthours = "two";
            break;
        case (3):
            resulthours = "three";
            break;
        case 4:
            resulthours = "four";
            break;
        case 5:
            resulthours = "five";
            break;
        case 6:
            resulthours = "six";
            break;
       case 7:
            resulthours = "seven";
            break;
         case 8:
            resulthours = "eight";
            break;  
         case 9:
            resulthours = "nine";
            break;
         case 10:
            resulthours = "ten";
            break;
         case 11:
            resulthours = "eleven";
            break;
         case 12:
            resulthours = "twelve";
            break;
         case (13): 
            resulthours = "one";
            break;
        case (14):
            resulthours = "two";
            break;
        case (15):
            resulthours = "three";
            break;
        case 16:
            resulthours = "four";
            break;
        case 17:
            resulthours = "five";
            break;
        case 18:
            resulthours = "six";
            break;
        case 19:
            resulthours = "seven";
            break;
         case 20:
            resulthours = "eight";
            break;  
         case 21:
            resulthours = "nine";
            break;
         case 22:
            resulthours = "ten";
            break;
         case 23:
            resulthours = "eleven";
            break;
         case 24:
            resulthours = "twelve";
            break;
         case -9:
            return 0;
      }
      
      switch (minutestr)
    {
        case 1:
            resultminutes = " one";
            break;
        case 2:
            resultminutes = " two";
            break;
        case 3:
            resultminutes = " three";
            break;    
        case 4:
            resultminutes = " four";
            break;  
        case 5:
            resultminutes = " five";
            break;    
        case 6:
            resultminutes = " six";
            break;    
        case 7:
            resultminutes = " seven";
            break;
        case 8:
            resultminutes = " eight";
            break; 
        case 9:
            resultminutes = " nine";
            break;
        case 10:
            resultminutes = " ten";
            break;
        case 11:
            resultminutes = " eleven";
            break;    
        case 12:
            resultminutes = " twelve";
            break; 
        case 13:
            resultminutes = " thirteen";
            break;
        case 14:
            resultminutes = " fourteen";
            break;
        case 15:
            resultminutes = " fifteen";
            break;  
        case 16:
            resultminutes = " sixteen";
            break; 
        case 17:
            resultminutes = " seventeen";
            break; 
        case 18:
            resultminutes = " eighteen";
            break; 
        case 19:
            resultminutes = " nineteen";
            break;
        case 20:
            resultminutes = " twenty";
            break;
        case 21:
            resultminutes = " twenty one";
            break;
         case 22:
            resultminutes = " twenty two";
            break;   
        case 23:
            resultminutes = " twenty three";
            break;
        case 24:
            resultminutes = " twenty four";
            break;
        case 25:
            resultminutes = " twenty five";
            break;
        case 26:
            resultminutes = " twenty six";
            break;
        case 27:
            resultminutes = " twenty seven";
            break;
        case 28:
            resultminutes = " twenty eight";
            break;
        case 29:
            resultminutes = " twenty nine";
            break;
        case 30:
            resultminutes = " thirty";
            break;
        case 31:
            resultminutes = " thirty one";
            break;
        case 32:
            resultminutes = " thirty two";
            break;
        case 33:
            resultminutes = " thirty three";
            break;
        case 34:
            resultminutes = " thirty four";
            break;
        case 35:
            resultminutes = " thirty five";
            break;
        case 36:
            resultminutes = " thirty six";
            break;
        case 37:
            resultminutes = " thirty seven";
            break;
        case 38:
            resultminutes = " thirty eight";
            break;
        case 39:
            resultminutes = " thirty nine";
            break;
        case 40:
            resultminutes = " forty";
            break;
        case 41:
            resultminutes = " forty one";
            break;
        case 42:
            resultminutes = " forty two";
            break;
        case 43:
            resultminutes = " forty three";
            break;
        case 44:
            resultminutes = " forty four";
            break;
        case 45:
            resultminutes = " forty five";
            break;
        case 46:
            resultminutes = " forty six";
            break;
        case 47:
            resultminutes = " forty seven";
            break;
        case 48:
            resultminutes = " forty eight";
            break;
        case 49:
            resultminutes = " forty nine";
            break;
        case 50:
            resultminutes = " fifty";
            break;
        case 51:
            resultminutes = " fifty one";
            break;
        case 52:
            resultminutes = " fifty two";
            break;
        case 53:
            resultminutes = " fifty three";
            break;
        case 54:
            resultminutes = " fifty four";
            break;
        case 55:
            resultminutes = " fifty five";
            break;
        case 56: 
            resultminutes = " fifty six";
            break;
        case 57:
            resultminutes = " fifty seven";
            break;
        case 58:
            resultminutes = " fifty eight";
            break;
        case 59:
            resultminutes = " fifty nine";
            break;
        case -59:
            return 0;
          
        }
      
          if (hours >= 12)
        { 
            time = " PM";
        }  
      else time = " AM";
      cout << resulthours << resultminutes << time << endl;
    } while (hours != -9 || minutes != -59);
      return 0;
}
This is my error report, which I do not understand at all.


1>------ Build started: Project: Lab 7test, Configuration: Debug Win32 ------
1> timetest1.cpp
1>timetest1.cpp(29): error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable conversion)
1> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\exception(470): could be 'bool std::operator ==(const std::_Exception_ptr &,const std::_Exception_ptr &)'
1> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\exception(475): or 'bool std::operator ==(std::_Null_type,const std::_Exception_ptr &)'
1> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\exception(481): or 'bool std::operator ==(const std::_Exception_ptr &,std::_Null_type)'
1> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\system_error(408): or 'bool std::operator ==(const std::error_code &,const std::error_condition &)'
1> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\system_error(416): or 'bool std::operator ==(const std::error_condition &,const std::error_code &)'
1> while trying to match the argument list '(std::string, int)'
1>timetest1.cpp(29): error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable conversion)
1> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\exception(470): could be 'bool std::operator ==(const std::_Exception_ptr &,const std::_Exception_ptr &)'
1> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\exception(475): or 'bool std::operator ==(std::_Null_type,const std::_Exception_ptr &)'
1> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\exception(481): or 'bool std::operator ==(const std::_Exception_ptr &,std::_Null_type)'
1> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\system_error(408): or 'bool std::operator ==(const std::error_code &,const std::error_condition &)'
1> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\system_error(416): or 'bool std::operator ==(const std::error_condition &,const std::error_code &)'
1> while trying to match the argument list '(std::string, int)'
1>timetest1.cpp(35): error C2450: switch expression of type 'std::string' is illegal
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>timetest1.cpp(113): error C2450: switch expression of type 'std::string' is illegal
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Here are some changes that I have done so far but still get the same error messages stated above......


// This program will let the user input the time and minutes in 24 hour format
// and printout on the screen the English time format. The program will continue
// until the user inputs -9 or -59.

#include "StdAfx.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;


int main()
{
string time;
string hourstr, minutestr;
do
{

cout << " Please input the hour in 24 hour format "<< endl;
cin >> hourstr;
cout << " Please input the minutes" << endl;
cin >> minutestr;
string resulthours;
string resultminutes;

if (hourstr == '12' && minutestr == '00')
{
cout << "Noon" << endl;
return 0;

}
else if (hourstr == '00' && minutestr == '00')
{
cout << "Midnight" << endl;
return 0;
}

switch (hourstr)
{
case '1':
resulthours = "one";
break;
case '2':
resulthours = "two";
break;
case '3':
resulthours = "three";
break;
case '4':
resulthours = "four";
break;
case '5':
resulthours = "five";
break;
case '6':
resulthours = "six";
break;
case '7':
resulthours = "seven";
break;
case '8':
resulthours = "eight";
break;
case '9':
resulthours = "nine";
break;
case '10':
resulthours = "ten";
break;
case '11':
resulthours = "eleven";
break;
case '12':
resulthours = "twelve";
break;
case '13':
resulthours = "one";
break;
case '14':
resulthours = "two";
break;
case '15':
resulthours = "three";
break;
case '16':
resulthours = "four";
break;
case '17':
resulthours = "five";
break;
case '18':
resulthours = "six";
break;
case '19':
resulthours = "seven";
break;
case '20':
resulthours = "eight";
break;
case '21':
resulthours = "nine";
break;
case '22':
resulthours = "ten";
break;
case '23':
resulthours = "eleven";
break;
case '24':
resulthours = "twelve";
break;
case '-9':
return 0;
}

switch (minutestr)
{
case '1':
resultminutes = " one";
break;
case '2':
resultminutes = " two";
break;
case '3':
resultminutes = " three";
break;
case '4':
resultminutes = " four";
break;
case '5':
resultminutes = " five";
break;
case '6':
resultminutes = " six";
break;
case'7':
resultminutes = " seven";
break;
case '8':
resultminutes = " eight";
break;
case '9':
resultminutes = " nine";
break;
case '10':
resultminutes = " ten";
break;
case '11':
resultminutes = " eleven";
break;
case '12':
resultminutes = " twelve";
break;
case '13':
resultminutes = " thirteen";
break;
case '14':
resultminutes = " fourteen";
break;
case '15':
resultminutes = " fifteen";
break;
case '16':
resultminutes = " sixteen";
break;
case '17':
resultminutes = " seventeen";
break;
case '18':
resultminutes = " eighteen";
break;
case '19':
resultminutes = " nineteen";
break;
case '20':
resultminutes = " twenty";
break;
case '21':
resultminutes = " twenty one";
break;
case '22':
resultminutes = " twenty two";
break;
case '23':
resultminutes = " twenty three";
break;
case '24':
resultminutes = " twenty four";
break;
case '25':
resultminutes = " twenty five";
break;
case '26':
resultminutes = " twenty six";
break;
case '27':
resultminutes = " twenty seven";
break;
case '28':
resultminutes = " twenty eight";
break;
case '29':
resultminutes = " twenty nine";
break;
case '30':
resultminutes = " thirty";
break;
case '31':
resultminutes = " thirty one";
break;
case '32':
resultminutes = " thirty two";
break;
case '33':
resultminutes = " thirty three";
break;
case '34':
resultminutes = " thirty four";
break;
case '35':
resultminutes = " thirty five";
break;
case '36':
resultminutes = " thirty six";
break;
case '37':
resultminutes = " thirty seven";
break;
case '38':
resultminutes = " thirty eight";
break;
case '39':
resultminutes = " thirty nine";
break;
case '40':
resultminutes = " forty";
break;
case '41':
resultminutes = " forty one";
break;
case '42':
resultminutes = " forty two";
break;
case '43':
resultminutes = " forty three";
break;
case '44':
resultminutes = " forty four";
break;
case '45':
resultminutes = " forty five";
break;
case '46':
resultminutes = " forty six";
break;
case '47':
resultminutes = " forty seven";
break;
case '48':
resultminutes = " forty eight";
break;
case '49':
resultminutes = " forty nine";
break;
case '50':
resultminutes = " fifty";
break;
case '51':
resultminutes = " fifty one";
break;
case '52':
resultminutes = " fifty two";
break;
case '53':
resultminutes = " fifty three";
break;
case '54':
resultminutes = " fifty four";
break;
case '55':
resultminutes = " fifty five";
break;
case '56':
resultminutes = " fifty six";
break;
case '57':
resultminutes = " fifty seven";
break;
case '58':
resultminutes = " fifty eight";
break;
case '59':
resultminutes = " fifty nine";
break;
case '-59':
return 0;

}

if (hourstr >= 12)
{
time = " PM";
}
else time = " AM";
cout << resulthours << resultminutes << time << endl;
} while (hourstr != -9 || minutestr != -59);
return 0;
}
Line 5: Get rid of stdafx.h if you're building a console application.

Line 26, 32: You need to use double quotes when comparing with a std::string.

Line 38,116: You can't use a string in a switch statement.

Lines 40-112, 118-295: Your case values are character literals, not numeric values.

Line 300,306: You can't compare a string to an int.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
Do you have the line numbers for the errors?

When you are comparing your strings hourstr and minutestr to check for noon and midnight you used == to compare to a char. This could be causing some of the errors. The other thing is you are using relational operators at the end of your program between strings and integers which definitely is causing an error. If you could post the line numbers I might be able to help you more but see if fixing the == between string and char helps and change the >= and != at the end of the program too.
How about this......


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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
// This program will let the user input the time and minutes in 24 hour format
// and printout on the screen the English time format.  The program will continue
// until the user inputs -9 or -59.

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;


int main()
{
	string time;
    string hourstr, minutestr; 
	string resulthours;
	string resultminutes;
	string hours;
	string minutes;
    do
    {
        
        cout << " Please input the hour in 24 hour format "<< endl;
        cin >> hours;
        cout << " Please input the minutes" << endl;
        cin >>  minutes; 
      
      if (hours == "12" && minutes == "00")
      {
          cout << "Noon" << endl;
                    
      }
      else if (hours == "00" && minutes == "00")
       {  
            cout << "Midnight" << endl;
           
      }
      
      switch (hours)
      {
        case "1": 
            resulthours = "one";
            break;
        case "2":
            resulthours = "two";
            break;
        case "3":
            resulthours = "three";
            break;
        case "4":
            resulthours = "four";
            break;
        case "5":
            resulthours = "five";
            break;
        case "6":
            resulthours = "six";
            break;
       case "7":
            resulthours = "seven";
            break;
         case "8":
            resulthours = "eight";
            break;  
         case "9":
            resulthours = "nine";
            break;
         case "10":
            resulthours = "ten";
            break;
         case "11":
            resulthours = "eleven";
            break;
         case "12":
            resulthours = "twelve";
            break;
         case "13": 
            resulthours = "one";
            break;
        case "14":
            resulthours = "two";
            break;
        case "15":
            resulthours = "three";
            break;
        case "16":
            resulthours = "four";
            break;
        case "17":
            resulthours = "five";
            break;
        case "18":
            resulthours = "six";
            break;
        case "19":
            resulthours = "seven";
            break;
         case "20":
            resulthours = "eight";
            break;  
         case "21":
            resulthours = "nine";
            break;
         case "22":
            resulthours = "ten";
            break;
         case "23":
            resulthours = "eleven";
            break;
         case z'24":
            resulthours = "twelve";
            break;
         case "-9":
			 break;
            
      }
      
      switch (minutes)
    {
        case "1":
            resultminutes = " one";
            break;
        case "2":
            resultminutes = " two";
            break;
		case "3":
            resultminutes = " three";
            break;    
		case "4":
            resultminutes = " four";
            break;  
		case "5":
            resultminutes = " five";
            break;    
		case "6":
            resultminutes = " six";
            break;    
		case "7":
            resultminutes = " seven";
            break;
		case "8":
            resultminutes = " eight";
            break; 
		case "9":
            resultminutes = " nine";
            break;
		case "10":
            resultminutes = " ten";
            break;
		case "11":
            resultminutes = " eleven";
            break;    
		case "12":
            resultminutes = " twelve";
            break; 
		case "13":
            resultminutes = " thirteen";
            break;
		case "14":
            resultminutes = " fourteen";
            break;
		case "15":
            resultminutes = " fifteen";
            break;  
		case "16":
            resultminutes = " sixteen";
            break; 
		case "17":
            resultminutes = " seventeen";
            break; 
		case "18":
            resultminutes = " eighteen";
            break; 
		case "19":
            resultminutes = " nineteen";
            break;
		case "20":
            resultminutes = " twenty";
            break;
		case "21":
            resultminutes = " twenty one";
            break;
		case "22":
            resultminutes = " twenty two";
            break;   
		case "23":
            resultminutes = " twenty three";
            break;
		case "24":
            resultminutes = " twenty four";
            break;
		case "25":
            resultminutes = " twenty five";
            break;
		case "26":
            resultminutes = " twenty six";
            break;
		case "27":
            resultminutes = " twenty seven";
            break;
		case "28":
            resultminutes = " twenty eight";
            break;
		case "29":
            resultminutes = " twenty nine";
            break;
		case "30":
            resultminutes = " thirty";
            break;
		case "31":
            resultminutes = " thirty one";
            break;
		case "32":
            resultminutes = " thirty two";
            break;
		case "33":
            resultminutes = " thirty three";
            break;
		case "34":
            resultminutes = " thirty four";
            break;
		case "35":
            resultminutes = " thirty five";
            break;
		case "36":
            resultminutes = " thirty six";
            break;
		case "37":
            resultminutes = " thirty seven";
            break;
		case "38":
            resultminutes = " thirty eight";
            break;
		case "39":
            resultminutes = " thirty nine";
            break;
		case "40":
            resultminutes = " forty";
            break;
		case "41":
            resultminutes = " forty one";
            break;
		case "42":
            resultminutes = " forty two";
            break;
		case "43":
            resultminutes = " forty three";
            break;
		case "44":
            resultminutes = " forty four";
            break;
		case "45":
            resultminutes = " forty five";
            break;
		case "46":
            resultminutes = " forty six";
            break;
		case "47":
            resultminutes = " forty seven";
            break;
		case "48":
            resultminutes = " forty eight";
            break;
		case "49":
            resultminutes = " forty nine";
            break;
		case "50":
            resultminutes = " fifty";
            break;
		case "51":
            resultminutes = " fifty one";
            break;
		case "52":
            resultminutes = " fifty two";
            break;
		case "53":
            resultminutes = " fifty three";
            break;
		case "54":
            resultminutes = " fifty four";
            break;
		case "55":
            resultminutes = " fifty five";
            break;
		case "56":
            resultminutes = " fifty six";
            break;
		case "57":
            resultminutes = " fifty seven";
            break;
		case "58":
            resultminutes = " fifty eight";
            break;
		case "59":
            resultminutes = " fifty nine";
            break;
		case "-59":
            break;
          
        }
      
          if (hours >= "12")
        { 
            time = " PM";
        }  
      else time = " AM";
      cout << resulthours << resultminutes << time << endl;
    } while (hours != "-9" || minutes != "-59");
      return 0;
} 
Last edited on
I changed the hours and minutes as integer numbers.....still getting a lot of errors..........

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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
// Programmer: David Weeks 
// Course Name: CIS 301 - Intro to Business Application Programming 
// Lab Number: Lab 7   
// This program will let the user input the time and minutes in 24 hour format
// and printout on the screen the English time format.  The program will continue
// until the user inputs -9 or -59.

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;


int main()
{
	string time;
  	string resulthours;
	string resultminutes;
	int hours;
	int minutes;
    do
    {
        
        cout << " Please input the hour in 24 hour format "<< endl;
        cin >> hours;
        cout << " Please input the minutes" << endl;
        cin >>  minutes; 
      
      if (hours == "12" && minutes == "00")
      {
          cout << "Noon" << endl;
                    
      }
      else if (hours == "00" && minutes == "00")
       {  
            cout << "Midnight" << endl;
           
      }
      
      switch (hours)
      {
        case "1": 
            resulthours = "one";
            break;
        case "2":
            resulthours = "two";
            break;
        case "3":
            resulthours = "three";
            break;
        case "4":
            resulthours = "four";
            break;
        case "5":
            resulthours = "five";
            break;
        case "6":
            resulthours = "six";
            break;
       case "7":
            resulthours = "seven";
            break;
         case "8":
            resulthours = "eight";
            break;  
         case "9" :
            resulthours = "nine";
            break;
         case "10":
            resulthours = "ten";
            break;
         case "11":
            resulthours = "eleven";
            break;
         case "12":
            resulthours = "twelve";
            break;
         case "13": 
            resulthours = "one";
            break;
        case "14":
            resulthours = "two";
            break;
        case "15":
            resulthours = "three";
            break;
        case "16":
            resulthours = "four";
            break;
        case "17":
            resulthours = "five";
            break;
        case "18":
            resulthours = "six";
            break;
        case "19":
            resulthours = "seven";
            break;
         case "20":
            resulthours = "eight";
            break;  
         case "21":
            resulthours = "nine";
            break;
         case "22":
            resulthours = "ten";
            break;
         case "23":
            resulthours = "eleven";
            break;
         case z'24":
            resulthours = "twelve";
            break;
         case "-9":
			 break;
            
      }
      
      switch (minutes)
    {
        case "1":
            resultminutes = " one";
            break;
        case "2":
            resultminutes = " two";
            break;
		case "3":
            resultminutes = " three";
            break;    
		case "4":
            resultminutes = " four";
            break;  
		case "5":
            resultminutes = " five";
            break;    
		case "6":
            resultminutes = " six";
            break;    
		case "7":
            resultminutes = " seven";
            break;
		case "8":
            resultminutes = " eight";
            break; 
		case "9":
            resultminutes = " nine";
            break;
		case "10":
            resultminutes = " ten";
            break;
		case "11":
            resultminutes = " eleven";
            break;    
		case "12":
            resultminutes = " twelve";
            break; 
		case "13":
            resultminutes = " thirteen";
            break;
		case "14":
            resultminutes = " fourteen";
            break;
		case "15":
            resultminutes = " fifteen";
            break;  
		case "16":
            resultminutes = " sixteen";
            break; 
		case "17":
            resultminutes = " seventeen";
            break; 
		case "18":
            resultminutes = " eighteen";
            break; 
		case "19":
            resultminutes = " nineteen";
            break;
		case "20":
            resultminutes = " twenty";
            break;
		case "21":
            resultminutes = " twenty one";
            break;
		case "22":
            resultminutes = " twenty two";
            break;   
		case "23":
            resultminutes = " twenty three";
            break;
		case "24":
            resultminutes = " twenty four";
            break;
		case "25":
            resultminutes = " twenty five";
            break;
		case "26":
            resultminutes = " twenty six";
            break;
		case "27":
            resultminutes = " twenty seven";
            break;
		case "28":
            resultminutes = " twenty eight";
            break;
		case "29":
            resultminutes = " twenty nine";
            break;
		case "30":
            resultminutes = " thirty";
            break;
		case "31":
            resultminutes = " thirty one";
            break;
		case "32":
            resultminutes = " thirty two";
            break;
		case "33":
            resultminutes = " thirty three";
            break;
		case "34":
            resultminutes = " thirty four";
            break;
		case "35":
            resultminutes = " thirty five";
            break;
		case "36":
            resultminutes = " thirty six";
            break;
		case "37":
            resultminutes = " thirty seven";
            break;
		case "38":
            resultminutes = " thirty eight";
            break;
		case "39":
            resultminutes = " thirty nine";
            break;
		case "40":
            resultminutes = " forty";
            break;
		case "41":
            resultminutes = " forty one";
            break;
		case "42":
            resultminutes = " forty two";
            break;
		case "43":
            resultminutes = " forty three";
            break;
		case "44":
            resultminutes = " forty four";
            break;
		case "45":
            resultminutes = " forty five";
            break;
		case "46":
            resultminutes = " forty six";
            break;
		case "47":
            resultminutes = " forty seven";
            break;
		case "48":
            resultminutes = " forty eight";
            break;
		case "49":
            resultminutes = " forty nine";
            break;
		case "50":
            resultminutes = " fifty";
            break;
		case "51":
            resultminutes = " fifty one";
            break;
		case "52":
            resultminutes = " fifty two";
            break;
		case "53":
            resultminutes = " fifty three";
            break;
		case "54":
            resultminutes = " fifty four";
            break;
		case "55":
            resultminutes = " fifty five";
            break;
		case "56":
            resultminutes = " fifty six";
            break;
		case "57":
            resultminutes = " fifty seven";
            break;
		case "58":
            resultminutes = " fifty eight";
            break;
		case "59":
            resultminutes = " fifty nine";
            break;
		case "-59":
            break;
          
        }
      
          if (hours >= "12")
        { 
            time = " PM";
        }  
      else time = " AM";
      cout << resulthours << resultminutes << time << endl;
    } while (!(hours = "-9" || minutes = "-59"));
      return 0;
} 
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
1
1>  testingtime.cpp
1>c:\users\david\documents\visual studio 2010\projects\lab 7.5\lab 7.5\testingtime.cpp(29): error C2446: '==' : no conversion from 'const char *' to 'int'
1>          There is no context in which this conversion is possible
1>c:\users\david\documents\visual studio 2010\projects\lab 7.5\lab 7.5\testingtime.cpp(29): error C2040: '==' : 'int' differs in levels of indirection from 'const char [3]'
1>c:\users\david\documents\visual studio 2010\projects\lab 7.5\lab 7.5\testingtime.cpp(29): error C2446: '==' : no conversion from 'const char *' to 'int'
1>          There is no context in which this conversion is possible
1>c:\users\david\documents\visual studio 2010\projects\lab 7.5\lab 7.5\testingtime.cpp(29): error C2040: '==' : 'int' differs in levels of indirection from 'const char [3]'
1>c:\users\david\documents\visual studio 2010\projects\lab 7.5\lab 7.5\testingtime.cpp(34): error C2446: '==' : no conversion from 'const char *' to 'int'
1>          There is no context in which this conversion is possible
1>c:\users\david\documents\visual studio 2010\projects\lab 7.5\lab 7.5\testingtime.cpp(34): error C2040: '==' : 'int' differs in levels of indirection from 'const char [3]'
1>c:\users\david\documents\visual studio 2010\projects\lab 7.5\lab 7.5\testingtime.cpp(34): error C2446: '==' : no conversion from 'const char *' to 'int'
1>          There is no context in which this conversion is possible
1>c:\users\david\documents\visual studio 2010\projects\lab 7.5\lab 7.5\testingtime.cpp(34): error C2040: '==' : 'int' differs in levels of indirection from 'const char [3]'
1>c:\users\david\documents\visual studio 2010\projects\lab 7.5\lab 7.5\testingtime.cpp(42): error C2051: case expression not constant
1>c:\users\david\documents\visual studio 2010\projects\lab 7.5\lab 7.5\testingtime.cpp(111): error C2065: 'z' : undeclared identifier
1>c:\users\david\documents\visual studio 2010\projects\lab 7.5\lab 7.5\testingtime.cpp(111): error C2143: syntax error : missing ':' before 'constant'
1>c:\users\david\documents\visual studio 2010\projects\lab 7.5\lab 7.5\testingtime.cpp(111): error C2051: case expression not constant
1>c:\users\david\documents\visual studio 2010\projects\lab 7.5\lab 7.5\testingtime.cpp(112): error C2146: syntax error : missing ';' before identifier 'resulthours'
1>c:\users\david\documents\visual studio 2010\projects\lab 7.5\lab 7.5\testingtime.cpp(114): error C2051: case expression not constant
1>c:\users\david\documents\visual studio 2010\projects\lab 7.5\lab 7.5\testingtime.cpp(117): warning C4060: switch statement contains no 'case' or 'default' labels
1>c:\users\david\documents\visual studio 2010\projects\lab 7.5\lab 7.5\testingtime.cpp(121): error C2051: case expression not constant
1>c:\users\david\documents\visual studio 2010\projects\lab 7.5\lab 7.5\testingtime.cpp(301): warning C4060: switch statement contains no 'case' or 'default' labels
1>c:\users\david\documents\visual studio 2010\projects\lab 7.5\lab 7.5\testingtime.cpp(303): error C2446: '>=' : no conversion from 'const char *' to 'int'
1>          There is no context in which this conversion is possible
1>c:\users\david\documents\visual studio 2010\projects\lab 7.5\lab 7.5\testingtime.cpp(303): error C2040: '>=' : 'int' differs in levels of indirection from 'const char [3]'
1>c:\users\david\documents\visual studio 2010\projects\lab 7.5\lab 7.5\testingtime.cpp(309): error C2106: '=' : left operand must be l-value
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Line 29,34,303: You're trying to compare ints to a quoted string.

Lines 42-114, 121-298: You're still trying to use quoted strings in your case labels. Your case labels should be simple numbers:
1
2
3
4
5
6
      switch (hours)
      {
        case 1:     // No quotes
            resulthours = "one";
            break;
...


Line 111: You've got an extraneous z and mismatched single and double quotes which should not be there at all.

Topic archived. No new replies allowed.