首页 > 其他 > 详细

60页 **2.6

时间:2017-09-17 23:25:37      阅读:264      评论:0      收藏:0      [点我收藏+]

package demo;
import java.util.Scanner;
public class bbb {

  public static void main(String[] args) {

    Scanner input = new Scanner(System.in);
    System.out.println("请输入一个0-1000之间的整数");
    int a =(int)input.nextDouble();

    if(a>999||a<0) {
      System.out.println("输入有误");

    }
    else if(a>0 && a<10){
      System.out.println("The sum of the digits is "+ a);
    }
    else if(a>9 && a<100) {
      int b=(a/10) + (a%10);
      System.out.println("The sum of the digits is "+ b);
    }
    else if(a>99 && a<1000) {
      int c=(a/100)+(a%100)+(a%10%10); 
      System.out.println("The sum of the digits is "+ c);
    }
  }

 

60页 **2.6

原文:http://www.cnblogs.com/777lixiaohui/p/7538385.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!