04-07-2005, 11:05 PM
Write a program that sums up all the multiples of 3 from 3 to 100 (of course the last one would be 99, not 100).
The total of all multiples of 3 from 1 to 100 is 1683 Write a program that keeps reading integers from the user until the number -1 is entered. Then print out the count of the numbers entered and their sum. See the sample input/output below for details. Notice that the message changes after the first number is entered. You should use a "priming read" for this program.
Please enter an integer (-1 to stop): ? 3
Please enter another integer (-1 to stop): ? 6
Please enter another integer (-1 to stop): ? 7
Please enter another integer (-1 to stop): ? -1
The sum of the 3 numbers you entered is 16
The total of all multiples of 3 from 1 to 100 is 1683 Write a program that keeps reading integers from the user until the number -1 is entered. Then print out the count of the numbers entered and their sum. See the sample input/output below for details. Notice that the message changes after the first number is entered. You should use a "priming read" for this program.
Please enter an integer (-1 to stop): ? 3
Please enter another integer (-1 to stop): ? 6
Please enter another integer (-1 to stop): ? 7
Please enter another integer (-1 to stop): ? -1
The sum of the 3 numbers you entered is 16