The purpose of the assignment is that you learn. Study your course material, think, and write as much as you can. If you still have problems, then show us your code and describe the specific issues.
Write a program that inputs hour in 24-hour format
You will need to ask for user input and store that in a variable. For more information and examples, please see: http://www.cplusplus.com/doc/tutorial/basic_io/
if the time is less than 4 pm print “Have a nice day” else print “Have a nice evening”
The above link will show you how to print text to the screen, as for the conditional part, please see: http://www.cplusplus.com/doc/tutorial/control/#if
Hope that helps, please do let us know if you have any further questions.
#include <iostream>
usingnamespace std;
int main ()
{
int hour,minute;
cout << "Enter Hour : ";
cin >> hour;
cout << "\nEnter Minute : ";
cin >> minute;
if ( ( hour < 0 || hour > 23 ) || ( minute < 0 || minute > 59)) //Validating Time Input, not being in minus or
cout << "\n\nInvalid Hour or Minute Value!!\n\n"; //Neither the Hour hits more than 23 or Minute hits more than 59
else
{
if ( hour >= 0 && hour < 16 ) //Hour must be between 12:00 AM and 3:59 PM
cout << endl << endl << "The Time is [ " << hour << " : " << minute << " ] \" Have a nice day \"\n\n";
else
cout << endl << endl << "The Time is [ " << hour << " : " << minute << " ] \" Have a nice evening \"\n\n"; //when Hour hits 4:00 PM or till 11:59 PM
}
return 0;//Success Exit
}
i know that for sure,it took me 10 minutes to make it with , he really should done that on his own, but i was hoping he will understand the concept by analyzing the code above, not just copy and paste it.. But i still agree with you EssGeEich.