CS1411 - Introduction to Programming Principles I

Programming / Lab Assignment 2

Write two programs, call them drink.cpp and weekday.cpp. Submit both in 1 zip file! Submit them according to the Submission guidelines.

The submission procedure has changed! Please check the labs page.

The first program should:

  • Ask the user to input an age (whole number) and store it
  • Ask the user to input how much money he has (floating point value) and store it
  • If he's at least 21 and has more than $5.00 output Let's go out!
  • If he's under 21, but has more than $7.00 output Let's go to a movie!
  • If none of the above applies output Let's meet at my place

Please note: for "more than $5.00 / $7.00" you may use either > or >=

The second program will calculate weekdays in 2004. It should

  • Define a enum type month jan, feb, mar, ..., dec, where jan=1
  • Define a enum type weekday: sun, mon, tue, ..., sat, where sun=0
  • Ask the user to input a month, and store it
  • Ask the user to input a day and store it
  • Calculate the weekday, that this day / month has in this year, using the following formula:
    Depending on the month, add an offset to the day of month: (jan: 3, Feb: 6, mar: 0, apr: 3, may: 5, jun: 1, jul: 3, aug:6, sep:2, oct: 4, nov:0, dec: 2)
    Calculate the weekday using modulo 7, could look like weekday = dayOfMonth % 7
    Typecast the new weekday to your weekday type
    Output somethine like Jan 4 2004 was a Sunday. You will need a switch statement for the month and one for the weekday

Your programs should include comments whith you name, testnumber, etc. in the top. See also the Submission guidelines

The assignment is due Friday Sept 17, 6pm. You have to submit it electronically as stated in the submission guidelines!

Lost? See the Help! page.