0
Program to enter an integer or double and add all the numbers in java
Can you give me any keyword or ideas from which i can create a program to enter an integer or double number and add them all? E.g. 360 = 3+6+0=9
6 ответов
+ 3
Take input as string, divide it into characters, convert each character to integer if possible (try/catch), calculate sum
+ 3
Shikaki ira K
Or you can use this
int n=360; int s=0;
while(n>0){
int d=n%10;
s+=d;
n/=10;}
+ 1
post your code
+ 1
Post your attempt
+ 1
So complete the course and then try again
0
Atul , i have got no any knowledge about this thing and i don't have no any keyword or idea to do it. So I haven't started my code yet.