Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA PLZ An emirp (prime spelled backwards) is a nonpalindromic prime number whose reversal is also a prime. For example, 17 is a prime and

JAVA PLZ

An emirp (prime spelled backwards) is a nonpalindromic prime number whose reversal is also a prime. For example, 17 is a prime and 71 is a prime, so 17 and 71 are emirps. 131 is a prime, but it is also a palindromic prime, so it is not an emirp. Write a program that displays the first 100 emirps. Display 10 numbers per line, separated by exactly one space. Sample output:

13 17 31 37 71 73 79 97 107 113 149 157 167 179 199 311 337 347 359 389 . . . 

Make use of the methods reverse and isPalindrome that you wrote in the previous assignment PalindromeInteger.java. See the hints in the coding template.

image text in transcribed

Load detault template... 1 import java.util.scanner; 3 public class Emirp 4 public static void main(String[] args) f Use a loop and an emirp counter ranging from 1 to 100 (When you have reached 100 emirps this program should stop producing emirps). Use a second counteri to generate potential emirps. Inside the body of the loop, call the methods ?SPrine(i), !isPalndrome(1), and ?sPrime(reverse(i)) to determine if i is an emirp When i is an emirp, increment the counter and also output i followed by a space. Every 10th emirp i needs to be output with a subsequent newline character instead of a space 6 7 10 public static boolean isPrime(int num) { 14 15 16 17 18 19 20 21 for (int i 2; i

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

What Is A Database And How Do I Use It

Authors: Matt Anniss

1st Edition

1622750799, 978-1622750795

More Books

Students also viewed these Databases questions

Question

state what is meant by the term performance management

Answered: 1 week ago