//P60 2.6
import java.util.Scanner; public class Demo_1{ public static void main(String[] agrs) { Scanner input = new Scanner(System.in); System.out.("Enter a number 0 and 1000: "); int number = input.nextInt(); int a = number%10; int b = number/10; int c = number/100; int sum = a + b + c; System.out.println("The sum of the digits is " + sum ); } }
时间: 2024-10-22 13:43:17