Homework Assignments
Homework 2
Sum Digits
Prompt the user for an integer and report the sum of all digits in the integer.
Example:
Enter an integer: 123
The sum of all digits in 123 = 6
You must use the following method to calculate the sum:
public static int sumDigits(int n)
Extra Credit:
Generate the following output for the input above:
1 + 2 + 3 = 6
using the following method:
public static String getStringOutput(int n)
Ultimately, your program should print the output using the following statement:
System.out.println( getStringOutput(n) + sumDigits(n) );
February 26, 2010 - 11:59pm
Announcements
CSNS All files must be submitted to CSNS prior to the due date/time.