Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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 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

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions

Question

1. Write down two or three of your greatest strengths.

Answered: 1 week ago

Question

What roles have these individuals played in your life?

Answered: 1 week ago

Question

2. Write two or three of your greatest weaknesses.

Answered: 1 week ago