CS52 Problem Set #2 Programming Projects Solved

25.00 $ 12.50 $

Category:

Description

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 % 19
b = year / 100
c = year % 100
d = b / 4
e = b % 4
f = (b + 8) / 25
g = (b – f + 1) / 3
h = ((19 * a) + b – d – g + 15) % 30
i = c / 4
j = c % 4
k = (32 + (2 * e) + (2 * i) – h – j) % 7
m = (a + (11 * h) + (22 * k) ) / 451

Easter Month = ( h + k – (7 * m) + 114 ) / 31                     where 3 means the month of March and 4 means April
p = ( h + k – (7 * m) + 114 ) % 31
Easter 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: 2006
Easter Month is April
Easter Day is 16

What’s the year: 2005
Easter Month is March
Easter Day is 27

What’s the year: 2004
Easter Month is April
Easter Day is 11

Submission Guidelines

    • Write a program which produces the same output as the examples above
        What’s the year: {USER INPUT}

 

      • 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

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 Cent
One Dollar Bill, Five Dollar Bill, Ten Dollar Bill, Twenty Dollar Bill
display 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.00
Enter an amount of purchases made against this amount: 18.52
The remaining change is: 13.48
Twenty US Dollar Bills: 0
Ten US Dollar Bills: 1
Five US Dollar Bills: 0
One US Dollar Bills: 3
Fifty US Cents Coins: 0
Twenty-Five US Cents Coins: 1
Ten US Cents Coins: 2
Five US Cents Coins: 0
One 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}

 

      • 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
  • 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.