读取整数

import java.util.Scanner;
  public class Duquzs{
  public static void main(String[] args){
    int i;
    Scanner input=new Scanner(System.in);
    System.out.print("Enter a number between 0 and 1000:");
    int t=input.nextInt();
    i=(t%10)+t/10%10+t/100%10;
    System.out.println("The sum of the digits is "+i);
  }
}

posted @ 2017-09-25 11:12  王泳钦  阅读(87)  评论(0)    收藏  举报