Question
In Java, An emirp (prime spelled backwards) is a nonpalindromic prime number whose is at least two digits and whose reversal is also prime. For
In Java, An emirp (prime spelled backwards) is a nonpalindromic prime number whose is at least two digits and whose reversal is also prime. For example, 17 is a prime number and 71 is a prime, so (17, 71) are an emirp pair. However, as specified above, they must be nonpalindromic prime numbers, so 11 or 131 or 313 would NOT be emirps.
Write a program that asks the user to enter the number of emirp pairs to display and the program will display those pairs. Do not display pairs more than once. Utilize a do-while loop to allow the user to try the program again (without having to re-run the program from your IDE), displaying the following message (exactly as shown) after displaying the emirp pairs:
// Ask user if they want to generate more emirp pairs
System.out.print(" Do you want to generate more emirp pairs (y)? ");
Ensure you do input validation on the number of emirp pairs the user enters (must be greater than or equal to 1).
Display 5 pairs per line, separated by exactly one space. So, for example, your first line must look like:
(13,31) (17,71) (37,73) (79,97) (107,701) .
For clarity, a prime number n must be greater than 1, and have only two factors: 1 and n. Make sure your program implements the following methods:
public static boolean isPrime(int num)
- Return true if number is prime public static int reversal(int number)
- Return an integer that has the parameters digits reversed public static boolean isPalindrome(int number)
- Return true if the number is a Palindrome
Please return this output with do-while loop in java.
An emirp (prime spelled backwards) is a nonpalindromic prime number whose is at least two digits and whose reversal is also prime. For example, 17 is a prime number and 71 is a prime, so (17,71) are an emirp pair. However, as specified above, they must be nonpalindromic prime numbers, so 11 or 131 or 313 would NOT be emirps. Write a program that asks the user to enter the number of emirp pairs to display and the program will display those pairs. Do not display pairs more than once. Utilize a do-while loop to allow the user to try the program again (without having to re-run the program from your IDE), displaying the following message (exactly as shown) after displaying the emirp pairs: // Ask user if they want to generate more emirp pairs System.out.print(" Do you want to generate more emirp pairs ( y ) ? "); Ensure you do input validation on the number of emirp pairs the user enters (must be greater than or equal to 1). Display 5 pairs per line, separated by exactly one space. So, for example, your first line must look like: (13,31)(17,71)(37,73)(79,97)(107,701) For clarity, a prime number n must be greater than 1, and have only two factors: 1 and n. Make sure your program implements the following methods: public static boolean isprime(int num) - Return true if number is prime public static int reversal (int number) - Return an integer that has the parameter's digits reversed public static boolean ispalindrome (int number) - Return true if the number is a PalindromeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started