public static void main(String[] args) {
int num = 321;
int sum = 0;
while (num > 0) {
sum = sum + num % 10;
num = num / 10;
}
System.out.println(sum);
}
Java Topics
Sending a prompt to the user
Accepting input from the user
testi.java Prompt user for n, output the first n numbers in the Fibonnacci sequence
Batting Averages
Read in a list of batting averages from the command line, store the
batting averages in an array, sort the array, and output the batting
averages from low to high.