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

Here is the question: Name the class MyMath and the static method isPerfect. Add

ID: 3617577 • Letter: H

Question

Here is the question:
Name the class MyMath and the static method isPerfect. Add thestatic isPrime method to your MyMath class. Create a static methodisMersennePrime in the MyMath class that determines if a number isa Mersenne prime. Create an application MyMathTest that displays amenu allowing the user to choose whether to display the primenumbers 1-1000, the Mersenne primes 1-10,000, the perfect numbers1-10,000, or to quit. Be sure to clearly label the output. Outputthe prime numbers 10 to a line. Use dialog boxes for ALL input andoutput.
Here are the first 10,000 primenumbers:
http://www.utm.edu/research/primes/lists/small/10000.txt
Here is some info about Mersenne prime numbers:
http://en.wikipedia.org/wiki/Mersenne_prime
Here is some info about perfect numbers:
http://en.wikipedia.org/wiki/Perfect_number
Here is the question:
Name the class MyMath and the static method isPerfect. Add thestatic isPrime method to your MyMath class. Create a static methodisMersennePrime in the MyMath class that determines if a number isa Mersenne prime. Create an application MyMathTest that displays amenu allowing the user to choose whether to display the primenumbers 1-1000, the Mersenne primes 1-10,000, the perfect numbers1-10,000, or to quit. Be sure to clearly label the output. Outputthe prime numbers 10 to a line. Use dialog boxes for ALL input andoutput.
Here are the first 10,000 primenumbers:
http://www.utm.edu/research/primes/lists/small/10000.txt
Here is some info about Mersenne prime numbers:
http://en.wikipedia.org/wiki/Mersenne_prime
Here is some info about perfect numbers:
http://en.wikipedia.org/wiki/Perfect_number

Explanation / Answer

I am unable to build MersennePrime Numbers.
import java.util.*;
class MyMath { private int num;
public static void isPerfect(int p) { int sum; int count=0; System.out.println("Perfect Numbers are given Below"); for(int v=1;v<=p;v++) { sum=0; for(int i=1;i<v;i++) { if(v%i==0) sum+=i; } if(sum==v) System.out.print(v+" "); } }

public static void isPrime(int n) { int v; int flag; int count=0; System.out.println("Primes Numbers are given below:"); for(v=1;v<=n;v++) { flag=0; for(int i=2;i<v;i++) { if(v%i==0) flag=1; } if(flag==0) { count++; if(count%11==0) System.out.println(); else System.out.print(v+" "); } } }
public static void main(String [] args) { MyMath m=new MyMath(); Scanner kb=new Scanner(System.in); while(true) { System.out.println(); System.out.println("Enter 1 to print all Primes(1-1000)"); System.out.println("Enter 2 to print all Perfect Numbers(1-1000)"); System.out.println("Enter 3 to quite the progame"); int c=kb.nextInt(); if(c==1) m.isPrime(1000); if(c==2) m.isPerfect(1000); if(c==3) break; } } } import java.util.*;
class MyMath { private int num;
public static void isPerfect(int p) { int sum; int count=0; System.out.println("Perfect Numbers are given Below"); for(int v=1;v<=p;v++) { sum=0; for(int i=1;i<v;i++) { if(v%i==0) sum+=i; } if(sum==v) System.out.print(v+" "); } }

public static void isPrime(int n) { int v; int flag; int count=0; System.out.println("Primes Numbers are given below:"); for(v=1;v<=n;v++) { flag=0; for(int i=2;i<v;i++) { if(v%i==0) flag=1; } if(flag==0) { count++; if(count%11==0) System.out.println(); else System.out.print(v+" "); } } }
public static void main(String [] args) { MyMath m=new MyMath(); Scanner kb=new Scanner(System.in); while(true) { System.out.println(); System.out.println("Enter 1 to print all Primes(1-1000)"); System.out.println("Enter 2 to print all Perfect Numbers(1-1000)"); System.out.println("Enter 3 to quite the progame"); int c=kb.nextInt(); if(c==1) m.isPrime(1000); if(c==2) m.isPerfect(1000); if(c==3) break; } } }