Need some help with some problems...

This is a discussion on Need some help with some problems... within the C++ Programming forums, part of the General Programming Boards category; Greetings from Japan, I'm asking for help on behalf of my wife. She's Japanese and decided to take an intro ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    1

    Question Need some help with some problems...

    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
    example:

    Enter the year (for example, 1999):
    1985
    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
    broadened capabilities.
    ---------------------
    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.

    Regards,

    James & Shinobu Keller

  2. #2
    Registered User *pointer's Avatar
    Join Date
    Oct 2001
    Posts
    74
    >Can you explain 'modulus' a bit better

    Modulus is the number remaining after a division operation. so if you had a statement like
    a = 11 % 2
    a would be assigned the value 1 because 11 / 2 is 5 with 1 left over.

    >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?

    That sounds right. You'll need one if statement to determine if the input was valid, then you'll no doubt need more if statements in your calculations.
    Code:
    if ( date is valid )
    {
        if ( something else )
        {
            /*perform calc */
        }
        else
        {
            /* perform alternate calc */
        }
    }
    else
    {
        printf( "Bad input" );
        exit(1);
    }
    pointer = NULL

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 02:59 AM
  2. C Pointers Problems
    By mhelal in forum C Programming
    Replies: 8
    Last Post: 01-10-2007, 05:35 AM
  3. String Manipulation problems -_-
    By Astra in forum C Programming
    Replies: 5
    Last Post: 12-13-2006, 04:48 PM
  4. contest problems on my site
    By DavidP in forum Contests Board
    Replies: 4
    Last Post: 01-10-2004, 08:19 PM
  5. DJGPP problems
    By stormswift in forum C Programming
    Replies: 2
    Last Post: 02-26-2002, 03:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21