第二次作业 读取整数

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-16 15:45  徐丶杨  阅读(109)  评论(0编辑  收藏  举报