(3) Palindrome Number  Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. For example, 12321 is a palindrome number. Follow up: Could you solve it without converting the integer to a string? Create a class named Palindrome which will contain the main method. All your code goes in the main method.              Sample Input and output: Example 1: Input: x = 121 Output: true Example 2: Input: x = -121 Output: false Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome Example 3: Input: x = 10 Output: false Explanation: Reads 01 from right to left. Therefore it is not a palindrome.   Example 4: Input: x = -101 Output: false   Example 5: Input: x = 3 Output: true

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter4: Making Decisions
Section: Chapter Questions
Problem 5E: a. Write a program named CheckMonth that prompts a user to enter a birth month. If the value entered...
icon
Related questions
Question

Language: JAVA  

PLEASE DO QUESTION 3 ONLY

  • PIN Lockout

Write a code to enter a 4-digit PIN as an integer, and check if the pin is valid (the valid PIN is 1234). If the PIN is not valid print an error message “INCORRECT PIN. TRY AGAIN.” and let the user enter the PIN again. But the user only has 3 tries to enter the correct PIN. If the user enters the wrong PIN for his/her 3 tries then print “YOU HAVE RUN OUT OF TRIES. ACCOUNT LOCKED.”  And if the user enters the valid PIN within the 3 tries print “PIN ACCEPTED. YOU NOW HAVE ACCESS TO YOUR ACCOUNT.”

Use a while loop to prompt the user to enter a valid PIN. Do not forget to print a prompt for the user asking to enter the PIN.

Create a class named PinLockout which will have the main method. All your code goes inside the main method.

            Sample input and output:

            Sample 1:

ENTER YOUR PIN: 2345

INCORRECT PIN. TRY AGAIN.

ENTER YOUR PIN: 2356

INCORRECT PIN. TRY AGAIN.

ENTER YOUR PIN: 7564

YOU HAVE RUN OUT OF TRIES. ACCOUNT LOCKED.

 

Sample 2:

ENTER YOUR PIN: 2345

INCORRECT PIN. TRY AGAIN.

ENTER YOUR PIN: 1234

PIN ACCEPTED. YOU NOW HAVE ACCESS TO YOUR ACCOUNT.

 

 

 

 

 

 

 

 

 

(2)  Reverse a number using while Loop

Write a java code that prompts the user to input a non-negative integer and then it will reverse the same number using a while loop. For example, if the input number is 25 the output should be 52.

            Sample input and output:

            Example 1:

            Input: 25

     Output: 52

            Example 2:

            Input: 123

     Output: 321

            Example 3:

            Input: 3

     Output: 3

           

 

 

 

(3) Palindrome Number 

Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. For example, 12321 is a palindrome number.

Follow up: Could you solve it without converting the integer to a string?

Create a class named Palindrome which will contain the main method. All your code goes in the main method. 

            Sample Input and output:

Example 1:

Input: x = 121

Output: true

Example 2:

Input: x = -121

Output: false

Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome

Example 3:

Input: x = 10

Output: false

Explanation: Reads 01 from right to left. Therefore it is not a palindrome.

 

Example 4:

Input: x = -101

Output: false

 

Example 5:

Input: x = 3

Output: true

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT