java,
分享于 点击 19730 次 点评:180
java,
import java.util.Scanner;
import javax.swing.JOptionPane;
public class javpro {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
JOptionPane.showMessageDialog(null,
"Enter a number between 0 and 1000: ");
System.out.println("Enter a number between 0 and 1000: ");
int t = input.nextInt();
int s = 0;
while (t>0) {
int a = t % 10;
t = t / 10;
s = s + a;
}
System.out.println("The sum of the digits is " + s);
}
}
相关文章
- 暂无相关文章
用户点评