Assignment 2

Date Assigned: November 5, 2007
Date Due: November 19, 2007

Write a Java program that will display 100 prime numbers. You may use the OO approach where methods that generate and show / display prime numbers belong to an object. The other approach that can be taken is to use all static methods that are nominally part of the class which contains the main method.

Submit source code and screen outputs.


Assignment 3

Date Assigned: November 7, 2007
Date Due: November 21, 2007

A perfect number is a positive integer such that the sum of the proper divisors equals the number. Thus, 28 = 1 + 2 + 4 + 7 + 14 is a perfect number. If the sum of the divisors is less than the number, it is deficient. If the sum exceeds the number, it is abundant.

  1. Write a Java program that allows the user to enter a positive integer and then displays the result indicating whether the number entered is perfect, deficient, or abundant.
  2. Write another Java program that will print all the perfect numbers that can be computed on your computer.

It is recommended that you use a nominal OO structure where by the methods belong to an object. Submit source code and screen outputs.


Static function samples found here.
Objects and methods samples found here.

A Prime Number Solution.
Array and Random Numbers Sample Example.