Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have developed a method (DetermineIfPrime) that determines if a number is prim

ID: 3713935 • Letter: I

Question

I have developed a method (DetermineIfPrime) that determines if a number is prime

public static boolean testIfPalindromeNumber(int n)
{
String originalString = Integer.toString(n);
String reverseString = "";
for(int i = originalString.length() - 1; i >= 0; --i)
{//open for loop
reverseString = reverseString + originalString.charAt(i);
}//end for loop
return originalString.equals(reverseString);
}//end testIfPalindromeNumber

You may use the methods above in your code (just copy and past).

Assignment:

1. Write a program (TypesOfPrimes.java) that has methods as follows (the methods you develop below should call the methods above as appropriate):

//determines if a number is a Sophie Germaine Prime (a number n such that n and 2 * n + 1 are both prime)
public static boolean isSophieGermainPrime(int n) e.g 2, 23, 89

//determines if a number is a Twin Prime (a number n such that n and n + 2 are both prime)
public static boolean isTwinPrime(int n) e.g 3,11,17

//determines if a number is prime and also palindromic (same forward and backwards)
public static boolean isPalPrime(int n) e.g 11, 101

//determines if the number passed is an emirp (a nonpalindromic prime number whose reverse is also prime)
public static boolean isEmirp(int n) e.g. 13

//determines if the number passed is a Mersenne Prime (a prime number n such that 2n - 1 is also prime)
public static boolean isMersenne(int n) e.g. e.g. 3, 7, 31, 127

2. Write another program (name it PrimeMethodsDemo.java) . Within the main method get an int from the user and pass it to the five methods above and print to the screen an appropriate messages given the value returned by the method called.

I want to rise to the power not multiply.

Explanation / Answer

Hi Dear,

Please find my implementation.

Please tell me if you have any issue.

#############

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote