need help urgent

closed account (EwCiz8AR)
please help me out it is assignment of my class plz somebody solve this

Write a program that inputs hour in 24-hour format and if the time is less than 4 pm print “Have a nice day” else print “Have a nice evening”

output
Enter time: 03:00
Have a nice day!
Last edited on
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.
Don't post homework questions

http://www.cplusplus.com/forum/beginner/1/
closed account (EwCiz8AR)
oky sorry now plz tell how to remove this topic ??
closed account (o3hC5Di1)
Hi there,

Let's break down your assignment:

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.

All the best,
NwN
This is such an easy assignment, you just needed to think about it a little bit ;)
So here is the program, and made it with a nice organized output

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
using namespace 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
}


Good Luck, Zaki
He was supposed to be doing it on his own... Whatever.

@OP: You can't remove a topic. Just leave it as it is, it will die and get archived (locked) soon.
Last edited on
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.
closed account (EwCiz8AR)
thanks for your reply :) i've done this work earlier
You are welcome anytime, it was pleasure.
Topic archived. No new replies allowed.