Numbers have fascinated
people for a
very long time.
Two interesting integer sequences are the
Fibonacci numbers and the
prime numbers.
Your task is to write a program that allows users to check if numbers they love (e.g., 16, 27,
28) are Fibonacci or prime numbers. (2.0%)
Your program must:
- Use a do-while loop to allow the user to enter up to 10 integers into an array.
Entry stops when the user enters zero.
You must do this in a separate method that returns the number of integers entered.
You may assume that the user will enter non-negative integers, but if you want to idiot-proof
your program, that would be cool. (0.5%)
- Use a for loop in the main method to go through the numbers in the array,
and for each number test if it is Fibonacci or prime.
The answer must be reported for each number. (0.25%)
- Have a method to test if a number is Fibonacci.
The function must accept an integer as a parameter, and return a boolean result.
The function must use a while loop to generate the Fibonacci numbers until the
integer if found or passed. (0.5%)
- Have a method to test if a number is prime.
The function must accept an integer as a parameter, and return a boolean result.
The function can use any technique to test if the integer is prime. (0.25%)
- Have regular comments for simple statements, have JavaDoc comments for the class, class
data, and all methods.
You must generate the web pages showing the documentation. (0.5%)
Here what a sample run should look like (with the keyboard input shown in italics) ...
Please enter numbers (0 to stop) : 13 27 21 29 0
13 is Fibonacci and is prime
27 is not Fibonacci and is not prime
21 is Fibonacci and is not prime
29 is not Fibonacci and is prime
Answer