Weekdays

In computing, we define data with numbers. On case where we might do that is with dates.

For this exercise, We will be reading in a number from the user, and telling them what day of the week it is. Here is how we will use numbers to represent days of the week.

Number Weekday
0 Sunday
1 Monday
2 Tuesday
3 Wednesday
4 Thursday
5 Friday
6 Satruday

Weekends

Start by making a program called weekdays.c that reads in a number. It should ask for the number with the message Enter a number from 0 to 6: Next, add a section to your program that tells the user if the day is a weekend. If the day is a weekend display the message n is a weekend.. If the day is not a weekend display the message n is not a weekend..

For example, if your program was run with the number 4, it would look like this:

Enter a number from 0 to 6: 4
4 is not a weekend.

Pay close attention to the examples and the text used there. as this will be checked by autotest.

Name of the day

Discuss how you might change your program to display the name of the day instead of the number. (Don’t spend too long on this.)

To run some simple automated tests:

$ 1511 autotest weekdays

To run Styl-o-matic:

$ 1511 stylomatic weekdays.c
Looks good!

You’ll get advice if you need to make changes to your code.

Submit your work with the give command, like so:

$ give cs1511 wk02_weekdays

Or, if you are working from home, upload the relevant file(s) to the wk02_weekdays activity on Give Online.