Question: Question: In JAVA, also why is my answer wrong, thanks! 3-12) (Palindrome number) Write a program that prompts the user to enter a three-digit integer

Question: In JAVA, also why is my answer wrong, thanks!

3-12) (Palindrome number) Write a program that prompts the user to enter a three-digit integer and determines whether it is a palindrome number. A number is a palindrome if it reads the same from right to left and fro:rm left to right. SAMPLE RUN #4: java Palindrome Hide Invisibles Highlight: Show Highlighted Only Enterathree-digitinteger:363 363isapalindrome

wrong answer:

import java.util.Scanner;

public class Palindrome{ public static void main(String[] args){

Scanner in = new Scanner(System.in);

System.out.print("Enter a three-digit integer:"); int user_input = in.nextInt();

int temp_remaning = 0;

int d1 = user_input % 10; temp_remaning = user_input / 10; int d2 = temp_remaning % 10; int d3 = temp_remaning / 10;

String rev = Integer.toString(d3) + Integer.toString(d2) + Integer.toString(d1); String original = Integer.toString(user_input);

if(rev.equals(original)){ System.out.println(original + " is a palindrome"); } else{ System.out.println(original + " is not a palindrome"); } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!