CMPT 225 Lab 0: Good morning, Good afternoon, and Good night!

CMPT 225 Lab 0: Good morning, Good afternoon, and Good night!


In this lab we will write a simple C++ program.

What to submit?

A hello.cpp file (with this exact file name) that takes an hour in the list of arguments and greets the user with "Good morning", "Good afternoon", or "Good night" without the quotes and go to the next line.

The input hour will be in 24 hour clock system (6:00pm will be given as 18:00). 5:00 - 11:59 is considered morning; 12:00 - 18:59 is considered afternoon; and 19:00 - 4:59 is considered night.

The file should run as follows:

uname@hostname:~$ g++ -o hello_world hello.cpp
uname@hostname:~$ ./hello_world 9:00
Good morning
uname@hostname:~$ ./hello_world  11
Good morning
uname@hostname:~$ ./hello_world  12:00
Good afternoon
uname@hostname:~$ ./hello_world  12:10
Good afternoon
uname@hostname:~$ ./hello_world  18
Good afternoon
uname@hostname:~$ ./hello_world  22:10
Good night
uname@hostname:~$ ./hello_world  3:30
Good night
uname@hostname:~$ ./hello_world  5
Good morning

Make sure the output is as expected before you submit your code.

Where to submit?

In CourSys under CMPT 225 Lab0 activity.

Some instructions on creating your file on a CSIL machine

All C++ programs start their execution at the main function. This is similar to Java, though different in that the C++ main function is not contained in a class. Here is a set of instructions to create a very simple main function that prints Hello world!.