求一整数各位数之和1636050052王智霞

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了求一整数各位数之和1636050052王智霞相关的知识,希望对你有一定的参考价值。

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

















以上是关于求一整数各位数之和1636050052王智霞的主要内容,如果未能解决你的问题,请参考以下文章