Greetings from Japan,
I'm asking for help on behalf of my wife. She's Japanese and decided to
take an intro to C++ programming course. Well, when she went to high school
there were no programming course...and she's stumped. I've tried to help her
thus far but need some help in understanding some of this too. It's very
interesting and has prompted me to take such a course as well. Please help!?
Here are the problems:
1. You can compute the date for any Easter Sunday from 1982 to 2048 as follows
(all variables are of type int):
a is year % 19
b is year % 4
c is year % 7
d is (19 * a + 24) % 30
e is (2 * b + 4 * c + 6 * d + 5) % 7
Easter Sunday is March (22 + d + e) *
Write a program that inputs the year and outputs the date (month and day) of
Easter Sunday for that year. Echo-print the input as part of the output. For
Enter the year (for example, 1999):
Easter is Sunday, April 7, in 1985.
Also, the algorithm for computing the date of Easter can be extended easily to
work with any year from 1900 to 2099. There are four years - 1954, 1981, 2049,
and 2076 - for which the algorithm gives a date that is seven days later than it
should be. Modify the program for this problem to check for these years and
subtract 7 from the day of the month. This correction does not cause the month
to change. Be sure to change the documentation for the program to reflect it's
Now, I've got what's it's saying and have a pretty good idea what needs to be
done...but my wife doesn't. Can you explain 'modulus' a bit better. Should
a be an integer variable that we define as such (as well as all the others) and
make it '=' year (which is also a integer variable) and put '%' as a function
before 19? Something like this:
a = year % 19
Also, we'll have to have an If/else statement that checks for the year, so that
it won't work before 1982 and 2048...right? And when we expand it it should
have additional If/Else statements that check for the special years mentioned
and subtract the 7 days from the date. Can you give some help on this.
2. Write a functional decomposition and a C++ program that inputs an integer
larger than 1 and calculates the sum of the squares from 1 to that integer. For
example, if the integer equals 4, the sum of the squares is 30 (1 + 4 + 9 +
16). The output should be the value of the integer and the sum, properly
labeled. The program should repeat this process for several input values. A
negative input value signals the end of the data.
No clue...please help!?
Thanks! We really appreciate any help you can offer.
James & Shinobu Keller