CS homework- Visual Studio
1
CS150 Assignment 3 Daycare Invoice Calculator
Date assigned: Friday, October 2, 2015 Part 1 due: Tuesday, October 13, 2015, 9:15am (25 points) Part 2 due: Monday, October 19, 2015, 1pm (25 points) You have been asked by a daycare provider to write a program to create monthly invoices for customers. Your program is to ask the user for the month, the year, and the cost per day. You will then output a monthly invoice showing the date, day of the month, charge for that day, and a running sum. After the table you are to display the total cost for that month. Below are some sample output screens using various input values:
2
Some things to note:
1. The daycare only charges for weekdays. 2. Assume that the user enters only valid numbers for the month, year, and daily cost. 3. Use setw to format the table as shown in the sample output. 4. All monetary amounts must be displayed to 2 decimal places. 5. There must be no magic constants in your program.
3
Determining if a year is a leap year You must determine if the year is a leap year so that you can provide a correct invoice for the month of February. A year is a leap year if it is divisible by 4. The only exception to this is if it is a century year. Then it is a leap year only if it is divisible by 400. Determining the day of the week of a particular date: To calculate the day on which a particular date falls, the following algorithm must be used:
a = (14 -‐ month) / 12
y = year -‐ a
m = month + 12 * a -‐ 2 dayOfWeek = (day + y + y/4 -‐ y/100 + y/400 + (31*m)/12) % 7
where year is the four-‐digit year, month is the integer between 1 and 12, day is the day of the month, and dayOfWeek is the day of the week. The value for dayOfWeek is 0 for Sunday, 1 for Monday, 2 for Tuesday, etc. All variables must be integers!
For example, if you were trying to find the day of the week on which 9/1/2014 falls, then you would substitute:
• 9 for month • 1 for day • 2014 for year
The result in dayOfWeek will be 1, which is a Monday.
Part 1 (Due 10/13): Name the project (03_A_DaycareCalculator)
For part 1, you must turn in a program that displays if a year is a leap year or not, the number of days in the entered month, and the day of the week that the month starts on in that particular year.
Sample output for part 1:
4
Part 2 (Due 10/19): Name the project (03_B_DaycareCalculator)
Submit the complete program as described on page 1.
To complete this assignment you must submit the following: 1. An electronic copy of your program on grace
a. Add new projects named 03_A_DaycareCalculator and 03_B_DaycareCalculator to your previously created assignment solution called PUNetIDAssignments. It is vital that you name your project correctly!
b. Type your program (fully documented/commented) into the project. The comment block at the top of the program needs to contain your name, the date the assignment is due, the class name, assignment number and name, and a brief description of the program.
c. Pay attention to the example output! Your program’s output must look exactly like the example output! The spacing and newlines in your output must match exactly.
d. Your program must use if statements, logical operators, constants, switch statements, and a while loop.
e. Make sure that your program compiles and runs correctly. If you get any errors (or warnings), double check that you typed everything correctly. Be aware that C++ is case-‐sensitive.
f. Once you are sure that the program works correctly it is time to submit your program. You do this by logging on to grace and placing your complete solution folder in the CS150-‐01 Drop folder. This solution folder must contain four projects: 01_Fraction, 02_BankFees, 03_A_DaycareCalculator, and 03_B_DaycareCalculator.
g. The program must be in the drop folder by 1pm on the day that it is due. Anything submitted after that will be considered late.
2. A hard copy of your program a. The hard copy must be placed on the instructor’s desk by 1pm on the day that it
is due.
b. The hard copy must be printed in color, double-‐sided, and stapled in the upper-‐ left corner if necessary. I do not bring a stapler to class.
Good luck! And remember, if you have any problems, come and see straight away. The printers in Marsh are slow. Do NOT expect to be able to print your code 10 minutes before class!