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

请把课堂作业的第2题提交至问卷星

A palindrome number is an integer that reads the same forwards and backwards.For example: 12321 is a palindrome number because it reads 12321 forwards and 12321 backwards.12345 is not a palindrome number because it reads 54321 backwards.You are developing a number validation tool and need to determine whether an integer is a palindrome number. Your task is to practice for loops, arithmetic operators, and if statements.Write a Java program named PalindromeNumber that completes the following tasks in the main method:

Step 1: Create VariablesCreate an int variable num with the value 12321; Create an int variable original to store the original value of num; Create an int variable reversed with an initial value of 0.

Step 2: Use a for Loop to Reverse the Number; Use a for loop to extract the last digit of num each time (num % 10); Multiply reversed by 10 and add the current digit; Divide num by 10 to remove the last digit

Step 3: Determine Whether It Is a Palindrome NumberIf original == reversed, it is a palindrome numberOtherwise, it is not a palindrome number

Step 4: Output the ResultsOutput in the following format:

Original: 12321

Reversed: 12321

Is Palindrome: true

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

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