+
۲

برنــــــــــــامه نویسی تمرکز - مجموع ارقام به زبان جاوا (اینجا کلیک کنید)

برنــــــــــــامه نویسی تمرکز - مجموع ارقام به زبان جاوا

import java.util.Scanner;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author sara
*/
public class sumrargham {
public static void main(String[] args) {
Scanner sara = new Scanner(System.in);
int n=sara.nextInt();
int sum=0;
while(n!=0){
sum+= n%10;
n/=10;

}
System.out.println("sum = "+sum);
}

}

 

رای دهندگان

دیدگاهتان را بنویسید