Summation Instructions While Loop
User Manual:
Open the PDF directly: View PDF
.
Page Count: 1
| Download | |
| Open PDF In Browser | View PDF |
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): Enter N: 33 The sum of all i, where i runs from 1 to 33 equals 561. 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: 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> When your program works correctly, submit it.
Source Exif Data:
File Type : PDF File Type Extension : pdf MIME Type : application/pdf PDF Version : 1.5 Linearized : No Page Count : 1 Language : en-US Tagged PDF : Yes Author : Hal Mendoza Creator : Microsoft® Word 2016 Create Date : 2017:10:02 10:36:54-07:00 Modify Date : 2017:10:02 10:36:54-07:00 Producer : Microsoft® Word 2016EXIF Metadata provided by EXIF.tools