CS PreAP: Major Project 1 Due: May... Project Title: Prime Numbers (Group Based) th

advertisement
CS PreAP: Major Project 1 Due: May 10th
Project Title: Prime Numbers (Group Based)
In this project, you will work with prime numbers.
Create a class called myPrimes. Class myPrimes will have three methods:
 Method isAPrime will take an input from the user and simply determine if
that numbers is a prime. Please see details below.
 Method primeFactors will take an input from the user and give its prime
factorization. Please see details below.
 Method rangePrimes will take two input from the user and list all prime
numbers within that range. Please see details below.
Method isAPrime:
This method will simply determine if a number entered is a prime. Indicate
whether it is a prime or not.
Method primeFactors:
This method will find the prime factorization of any number.
All non prime numbers have prime factors. That is, prime numbers that can
be multiplied together to get that number.
For example, the prime factorization of 100 is:
2*2*5*5 (both 2 and 5 are primes).
The prime factorization of 93 is
3*31 (both 3 and 31 are primes)
I must be able to enter any number, and I mean any number. I should be able
to enter 1539871 and get results. Display the prime factorization in ascending
order. If a number is a prime itself, say so.
Method rangePrimes:
This method will list all the prime numbers between x and y, with x and y
being user input.
If I enter 10 and 20 for x and y, it should list:
11, 13, 17, 19
I should be able to list any two ranges and it will yield prime all the prime
numbers between.
To begin this project, you will first turn in some pseudocode for your project.
Please see “Project1 – Pseudocode” to determine what to do. This will be
counted as a lab grade.
For credit for this project, please see “Project1 – Rubric” to see how you will be
graded.
In void main, give me 4 options:
1.
2.
3.
4.
Test if a number is prime
Get prime factors
Get prime numbers between two numbers
Exit
Program should continue until I choose exit.
This lab is too big for one person to do everything. Every member of the group
must participate. While you may have a lead programmer, 3 people sitting
around and watching one person code is not a good idea.
Any use of Java’s pre written libraries will result in a zero for the group. If you
have any questions about a method, please ask.
You may declare whatever instance variables and other methods you need inside
your class to pull off your program.
Download