Answered You can hire a professional tutor to get the answer.

QUESTION

Class PrimeNumbers : o Declare two private fields:

I need some help with a programming lab.

·       Class PrimeNumbers:

o  Declare two private fields: integer numberOfPrimes, and array of integers primes

o  Write a method called getNumberFromUser which prompts the user to enter a value into the numberOfPrimes and create the array for primes field.

o  Write a method called generatePrimes (finds prime numbers based on previous prime numbers) based on the following PDL:

START generatePrimes

primes0 ß 2

primeNumbers ß 1

current ß 3

WHILE primeNumbers < numberOfPrimes

isPrime ß true

previousPrime ß 0

WHILE previousPrime < primeNumbers

IF current MOD primespreviousPrime EQUAL 0

isPrime ß false

ENDIF

previousPrime ß previousPrime + 1

ENDWHILE

IF isPrime

primesprimeNumbers ß current

primeNumbers = primeNumbers + 1

ENDIF

current ß current + 2

ENDWHILE

END generatePrimes

o  Write a method called printPrimes to display the array

·       Class Lab7

o  In your method main, print this statement to the screen "Program developed by name" and insert your name into the statement

o  declare an object of PrimeNumbers

o  execute the methods getNumberFromUser, generatePrimes and printPrimes on this object

Bonus:

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question