Question

Does someone know how to solve this in java code? I'm taking programming level 1 Write...

Does someone know how to solve this in java code? I'm taking programming level 1

Write a program that prompts the user to enter a three-digit integer and determines whether it is a palindrome number. A number is palindrome if it reads the same from right to left and from left to right.  

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*;
class Driver{  
public static void main(String args[]){  
int r,sum=0,temp;   
int n = 0;
Scanner in = new Scanner(System.in);
System.out.println("Enter number");
n = in.nextInt();
temp=n;   
while(n>0){   
r=n%10;  
sum=(sum*10)+r;   
n=n/10;   
}   
if(temp==sum)   
System.out.println("Given number is palindrome");   
else   
System.out.println("Given number is not palindrome");   
}  
}  

<terminated> Driver (3) [Java Application] C Pro Enter number 454 iven number is palindrome

**Comment for any further queries. Upvote if the answer is satisfactory

Add a comment
Know the answer?
Add Answer to:
Does someone know how to solve this in java code? I'm taking programming level 1 Write...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JAVA: 4.31 (Palindromes) A palindrome is a sequence of characters that reads the same backward as...

    JAVA: 4.31 (Palindromes) A palindrome is a sequence of characters that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write an application that reads in a five-digit integer and determines whether it’s a palindrome. If the number is not five digits long, display an error message and allow the user to enter a new value.

  • Problem 1. A palindrome is a sequence of characters that reads the same backward as forward....

    Problem 1. A palindrome is a sequence of characters that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write an application that reads in a five-digit integer and determines whether it is a palindrome. If the number is not five digits long, display an error message and allow the user to enter a new value. Problem 2. Modify the program to determine whether a seven-digit number...

  • Write an application in java that reads in a five-digit integer and determines whether it is...

    Write an application in java that reads in a five-digit integer and determines whether it is a palindrome. If the number is not five digits long, display an error message and allow the user to enter a new value. Tips: 1. Determine the number of digits in the value input by the user , i.e. prompt the user to enter the number of digits of the number. Use a while loop to determine whether the user input contains the proper...

  • write programs with detailed instructions on how to execute. code is java What you need to...

    write programs with detailed instructions on how to execute. code is java What you need to turn in: You will need to include an electronic copy of your report (standalone) and source code (zipped) of your programs. All programming files (source code) must be put in a zipped folder named "labl-name," where "name" is your last name. Submit the zipped folder on the assignment page in Canvas; submit the report separately (not inside the zipped folder) as a Microsoft Word...

  • A palindrome is a sequence of characters that reads the same backward as forward. For example,...

    A palindrome is a sequence of characters that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write an application that reads in a five-digit integer and determines whether it's a palindrome. If the number is not five digits long, display an error message and allow the user to enter a new value.

  • 1. Palindrome Write a program that prompts the user for a positive integer number and output whet...

    Language is C 1. Palindrome Write a program that prompts the user for a positive integer number and output whether the number is a palindrome or not. A palindrome number is a number that is the same when reversed. For example, 12321 is a palindrome; 1234 is not a palindromoe. You will write a function named as palindrome. The function will have two arguments, number and isPalindrome. Both arguments are pass-by-reference. The argument number is a pointer to a variable...

  • 1. DOES A DIGIT APPEAR IN AN INTEGER, Write a recursive function appears(n,i) that returns true...

    1. DOES A DIGIT APPEAR IN AN INTEGER, Write a recursive function appears(n,i) that returns true if the digit i appears in the positive (base 10) integer n, false if it does not in c++. ex. Enter a positive integer: 54321 Enter a digit: 7 The digit 7 does NOT appear in the integer 54321. 2. IS AN INPUT STRING A PALINDROME? A palindrome is a string in which the letters are the same in both directions, disregarding capitalization and...

  • Please Code in Java and follow the directions given Thanks Program required Directions .A palindrome is a str...

    Please Code in Java and follow the directions given Thanks Program required Directions .A palindrome is a string that reads the same forward and backward, i.e., the letters are the same whether you read them from right to left or from left to right. Examples: 3 a) radar à is a palindrome b)Able was I ere I saw Elba à is a palindrome e good à not a palindrome Write java program to read a line of text and tell...

  • (Palindrome integer) Write the functions with the following headers: # Return the reversal of an integer,...

    (Palindrome integer) Write the functions with the following headers: # Return the reversal of an integer, e.g. reverse(456) returns # 654 def reverse(number): # Return true if number is a palindrome def isPalindrome(number): Use the reverse function to implement isPalindrome. A number is a palindrome if its reversal is the same as itself. Write a test program that prompts the user to enter an integer and reports whether the integer is a palindrome.

  • Write a program palind.c that reads a message, then checks whether it's palindrome (the letters in...

    Write a program palind.c that reads a message, then checks whether it's palindrome (the letters in the message are the same from left to right as from right to left): Enter a message He lived as a devil, eh? Palindrome Enter a message Madam, I am Adam Not a palindrome Ignore all characters that aren't letters. Use integer variables to keep track of positions in the array. Revise the program in Part I to use a pointer instead of an...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT