Program 2

advertisement
CMPS 161
PROGRAMMING ASSIGNMENT II
FALL 2007
Due Date October 4, 2007[20 POINTS]
Write a Java program that reads an integer between 0 and 1000 and adds all the digits
in the integer. For example, if an integer is 932, the sum of all its digits is 14.
Use the % operator to extract digits, and use the / operator to remove the extracted
digit. For example, 932 % 10 = 2 and 932 / 10 = 93
Sample Output:
Important Notes:
1. The program must be submitted on or before the due date unless the student has a
valid excuse. I will deduct 10% for everyday that the assignment is late.
2. Save the program under the name program2.
3. A hardcopy of the program must be submitted with the flash drive, CD, or uploaded
to the digital drop box in a folder.
4. The program must include ample documentation to explain its purpose.
5. The declaration and statement sections must be preceded by comments to show the
grader where the sections of the program start. (e.g. // Local Declarations).
6. You must include the following information in your documentation: Name, Program
number, and Section number, and program due date.
DR. G. ALKADI
Download