(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
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
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
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images