Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program, An emirp (prime spelled backwards) is a nonpalindromic prime number whose is at least two digits and whose reversal is also

Write a Java program, 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/n)? "); 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Icdt 88 2nd International Conference On Database Theory Bruges Belgium August 31 September 2 1988 Proceedings Lncs 326

Authors: Marc Gyssens ,Jan Paredaens ,Dirk Van Gucht

1st Edition

3540501711, 978-3540501718

More Books

Students also viewed these Databases questions