[Java]
/*
* Start the program header annotation.
* Copyright and version Declaration of the program
* Copyright (c) 2011, a student from the computer College of Yantai University
* All rights reserved.
* File name: calculates the sum of individual digits.
* Author: Xue Guangchen
* Completion date: January 1, September 15, 2011
* Version No.: x1.0
* Description of tasks and Solutions
* Input description:
* Problem description: enter an integer on the keyboard to calculate the sum of individual digits.
* Program output:
* End the comment in the program Header
*/
Package xue.com;
Public class Sum {
/**
* @ Param args
*/
Public static void main (String [] args ){
// TODO Auto-generated method stub
Int s = 0, B = 0;
System. out. println ("enter an integer :");
Int number = Console. readInt ();
Int m = number;
While (m! = 0)
{
B = m % 10;
M = m/10;
S = s + B;
}
System. out. println ("the sum of individual digits is :");
System. out. println (s );
}
}
Running result:
Enter an integer:
137
The sum of individual digits is:
11