a-easter_calculator
Our current calendaring system is the Gregorian Calendar which took effect in 1583. One thing that is very hard to determine is the date of Easter each year. In 1876, the following algorithm was proposed for producing the date of Easter. At a later time, Samuel Butcher, the Bishop of Meade, showed that this algorithm is, in fact, accurate for all years in our current calendaring system.
a = year % 19b = year / 100c = year % 100d = b / 4e = b % 4f = (b + 8) / 25g = (b – f + 1) / 3h = ((19 * a) + b – d – g + 15) % 30i = c / 4j = c % 4k = (32 + (2 * e) + (2 * i) – h – j) % 7m = (a + (11 * h) + (22 * k) ) / 451Easter Month = ( h + k – (7 * m) + 114 ) / 31 where 3 means the month of March and 4 means Aprilp = ( h + k – (7 * m) + 114 ) % 31Easter Date = p + 1
In all the calculations above, / means integer division which neglects the remainder and % means the modulus operation which performs integer division and keeps only the remainder. For both of the previous operations to translate correctly in C++, you must have declared int datatypes on either side of the / and % sign. Also, please remember the order of operations which demand that multiplications occur before additions, as expressed by the parentheses I have placed in these formulas. Write a C++ program that prompts for a year and then calculates the date of Easter. A sample program dialogue is shown below.
HINT: You might try building these calculation inside Excel and then do them step-by-step, verifying the values calculated in your program against your spreadsheet answers…
What’s the year: 2006Easter Month is AprilEaster Day is 16
What’s the year: 2005Easter Month is MarchEaster Day is 27
What’s the year: 2004Easter Month is AprilEaster Day is 11
Submission Guidelines
-
- Write a program which produces the same output as the examples above
What’s the year: {USER INPUT}
- Write a program which produces the same output as the examples above
-
-
Easter Month is {MONTH NAME}
-
-
-
Easter Day is {DAY}
-
- You are given a main.cpp file.You must implement the findEasterDate() method through files you must supplement.All files must be compile with the given main without having to modify the main file itself.
- Your submission should follow this organization:
- part-a
- main.cpp
- my_easter_calculator.h
- my_easter_calculator.cpp
- part-a
b-change_calculator
Write a C++ program that prompts for a cash value and an amount of purchases made against that amount. The program should then determine the change using US paper and coin currency. Working with the following bills and coins:Fifty Cents, Twenty-Five Cents, Ten Cents, Five Cents, One CentOne Dollar Bill, Five Dollar Bill, Ten Dollar Bill, Twenty Dollar Billdisplay how many of each would be needed to make the change. In order to receive full credit, you must use a loop. The program dialog would look like:
Enter a value: 32.00Enter an amount of purchases made against this amount: 18.52The remaining change is: 13.48Twenty US Dollar Bills: 0Ten US Dollar Bills: 1Five US Dollar Bills: 0One US Dollar Bills: 3Fifty US Cents Coins: 0Twenty-Five US Cents Coins: 1Ten US Cents Coins: 2Five US Cents Coins: 0One US Cent Coins: 3
Continue(y/n)?n
HINT: You really should use integer arithmetic to ensure that your calculations, down to that very last penny, are exact and accurate.HINT: The % (modulus operator) is very helpful in computing remainders but requires two int parameters.
Submission Guidelines
-
- Write a program which produces the same output as the examples above
The remaining change is: {CHANGE}
- Write a program which produces the same output as the examples above
-
-
Twenty US Dollar Bills: {VALUE}
-
-
-
Ten US Dollar Bills: {VALUE}
-
-
-
Five US Dollar Bills: {VALUE}
-
-
-
One US Dollar Bills: {VALUE}
-
-
-
Fifty US Cents Coins: {VALUE}
-
-
-
Twenty-Five US Cents Coins: {VALUE}
-
-
-
Ten US Cents Coins: {VALUE}
-
-
-
Five US Cents Coins: {VALUE}
-
-
-
One US Cent Coins: {VALUE}
-
- You are given a main.cpp file.You must implement the calculateChange() method through files you must supplement.All files must be compile with the given main without having to modify the main file itself.
- Your submission should follow this organization:
- part-b
- main.cpp
- my_change_calculator.h
- my_change_calculator.cpp
- part-b
- Currency output must output to proper precision.For example, ‘The remaining change is: 1.200000’ will result in deductions.
REGARDING THE ENTIRE ASSIGNMENT:
- Failing to follow these guidelines will result in deductions.
- I will also be grading for proper style, formatting and comments.
Reviews
There are no reviews yet.