 |
|
Lab
3
Objective
Classwork:
-
Write a method
integerPower ( base , exponent ) that returns the value of base
exponent . For example,
integerPower(3,4)=3*3*3*3. Assume that exponent is a positive, nonzero integer
and base is an integer. Method integerPower should use for or
while to control thr calculation. Don�t use any math library
methods. Incorporate this method into an applet that reads integer value from
JTextField for base and exponent from the user and perform the
calculation with the integerPower method.
-
An integer is
said to be prime if it is divisible only by 1 and itself. For
example, 2, 3, 5 and 7and prime, but 4,6, and 8 are not.
�
Write a method that
determines if a number is prime.
�
Use this method in an
applet that determines and prints all the prime numbers between 1 And 10,000.
Display the result in a JtextArea that has scrolling
functionality.
|
|
|