200字
2026-09-24 课堂任务与课后作业
2026-09-23
2026-09-23

程序运行网站:

https://www.jyshare.com/compile/10/

课堂任务:

A Narcissistic Number is a three-digit number whose sum of the cubes of its digits equals the number itself. For example: 153 is a Narcissistic Number because 1³ + 5³ + 3³ = 1 + 125 + 27 = 153. You are developing a math tool and need to find all Narcissistic Numbers between 100 and 999. Your task is to practice for loops, arithmetic operators, and if statements.Write a Java program named NarcissisticNumber that completes the following tasks in the main method:
Step 1: Use a for loop to iterate from 100 to 999.

Step 2: Decompose the three-digit number. Use the arithmetic operators / and % to extract the hundreds, tens, and ones digits.

Hundreds digit: num / 100;Tens digit: (num / 10) % 10;Ones digit: num % 10;

Step 3: Determine whether it is a Narcissistic Number. Calculate the sum of the cubes of each digit. If the sum of the cubes equals the original number, output that number.

Step 4: Output in the following format:

请提交代码截图至问卷星https://v.wjx.cn/vm/PMpN93K.aspx#

2026-09-24 课堂任务与课后作业
作者
Administrator
发表于
2026-09-23
License
CC BY-NC-SA 4.0