import java.util.Scanner;
public class Main {
/**
* @param args
* the command line arguments
*/
public static void main(String[] args) {
int total = 0, num = 0;
int i = 0;
Scanner in = new Scanner(System.in);
System.out.println("Enter a number");
num = in.nextInt();
for (; i <= num; i++) {
total += num % 10;
num /= 10;
}
System.out.println(total);
}
}
Edited by Alexander, 23 November 2010 - 02:47 PM.
[code][/code] tags


Sign In
Create Account


Back to top









