读取整数,

读取整数,

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);
  }
}

图片 1

 

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...

本文由js9905com金沙网站-金沙澳门手机版网址发布于计算机,转载请注明出处:读取整数,

您可能还会对下面的文章感兴趣: