Summation Instructions While Loop

User Manual:

Open the PDF directly: View PDF PDF.
Page Count: 1

COMP B11 Summation
Instructions
Create class Summation, which shall add up numbers from 1 to N.
The main method in Summation should perform the summation and output the result
in the format shown in the example below.
Summation should:
Prompt the user to enter an integer
Read the integer
Use a while loop to calculate the sum of all the integers from 1 to the integer
the user entered.
Print out the sum calculated with the while loop, in the format shown in the
example below.
Thus, if the user enters, for instance, 12, your program should output 78.
Be sure your indentation and documentation are correct.
Example run (input in bold):
To test your program, obtain AutoGrade.jar. Put it and a copy of your
Summation.java in the same directory. Then run it as shown in the example below:
When your program works correctly, submit it.
Enter N: 33
The sum of all i, where i runs from 1 to 33 equals 561.
MYPROMPT> java -jar AutoGrade.jar Summation
Compilation is successful
Input value: 414
Right Answer: "The sum of all i, where i runs from 1 to 414 equals 85905."
Your Answer: "The sum of all i, where i runs from 1 to 414 equals 85905."
Score: 100%
MYPROMPT>

Navigation menu