I'm Finishing up my finals and my brain is fried. Why oh why is this nested if not setting the value (hour += 12 ) properly?
1 2 3 4 5 6 7 8 9 10 11 12 13
cout << "hours:";
cin >> hour;
if (hour > 12)
{
hour += 12;
if (hour > 17)
{
cout << "Office hours do not end later than 5:00pm \n";
cout << "Please enter your starting time: \n";
cout << '\n';
}
}
what are you trying to accomplish? I'm confused by your code also.
if you are just trying to print out the message if somebody enters a value greater than 17 then i don't think you would need to nest the second if statement.
That makes sense in english but not for a computer.
The person should have already input the hour with +12 in it by the time it reaches your if statement.
You don't need to add 12 unless you are going to add a feature that would let you check if it was AM or PM. Then you wouldn't ask the person to add 12 to begin with.