Thread: Is this possible?

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    7

    Is this possible?

    I have to create a program that will sum and average a series of numbers. I know how to do that, but the way that we are supposed to input the numbers throws me off. Say the numbers you have are 5, 6, 9 and 3. We are supposed to enter them as follows: 5 6 9 3 0, with the zero telling the program that those are all of the numbers. How can I do this?

  2. #2
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Read the numbers inside a loop until you encounter value 0.

  3. #3
    Registered User
    Join Date
    Apr 2010
    Posts
    7
    So inside a while loop where the variable would be not equal to 0? But how would I define the variables?

  4. #4
    Novice
    Join Date
    Jul 2009
    Posts
    568
    Do you really need to assign each number read from the input to a distinct variable?

    Think about what data you really need in order to compute the weighted average of a series of numbers.

  5. #5
    Registered User
    Join Date
    Apr 2010
    Posts
    7
    I actually figured out what the problem was, thanks. If anyone wants me to post it I can.

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Welcome to the forum, Vmckoon2!

  7. #7
    Novice
    Join Date
    Jul 2009
    Posts
    568
    Quote Originally Posted by vmckoon2 View Post
    I actually figured out what the problem was, thanks. If anyone wants me to post it I can.
    I'm curious what your solution is. Please post it.

Popular pages Recent additions subscribe to a feed