SumOfInput.java 457B

1234567891011121314151617181920212223
  1. /**
  2. * Write a description of class SumOfInput here.
  3. *
  4. * @author Zavon Malone
  5. * @version 10/21/18
  6. */
  7. import java.util.Scanner;
  8. public class SumOfInput
  9. {
  10. public static void sumOfInput(String args[]){
  11. int i, n, sum = 0;
  12. Scanner num = new Scanner (System.in);
  13. System.out.print("Enter number");
  14. i = num.nextInt();
  15. while(i>0){
  16. n = i % 10;
  17. sum = sum + n;
  18. i = i / 10;
  19. }
  20. System.out.println("Number Sum "+sum);
  21. }
  22. }