Programming Assignment IV - Due: Thursday July 30, 2000
Arrays
Your final program will involve two parts. You will prompt the user for which part they want to
execute.
The first option that you will give the user is to have you sort an array of randomly generated
ints between 0 and a certain number. They will input how many numbers you should generate and
what the maximum number to be generated is. For example, they might ask you to produce 20 random
ints between 0 and 500. You will sort the array and determine the following information.
The minimum number generated.
The maximum number generated.
The number of prime numbers generated.
The number of even numbers generated.
The number of odd numbers generated.
The minimum prime number generated.
The maximum prime number generated.
The sum of all prime numbers generated.
You may produce random numbers using the Math.random() method. It returns a double between 0.0 and
1.0. So to produce a random number between 0 and a certain number, you would multiply the result
of
Math.random() by that number and cast it as an int.
The second option that you will present to the user will be for you to produce a table of
logarithms for them. The table will be stored in a two-dimensional array.
The rows in the array will represent tenths of numbers, that is, the first row will represent 1.0,
the second row will represent 1.1, the third row will represent 1.2, etc. The last row in the
array will represent 10.0.
The columns in the array will represent hundreths of numbers up to 0.09. That is the columns will
represent the numbers 0.00, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, and 0.09.
The user will input what base to use, and each entry in the array will be the logarithm to that
base of the sum of the numbers represented by the row and column.
For example, the first entry in the table will the logarithm to the base of the input number of
1.0 + 0.00.
The logarithms can be computed using the Math.log() method and the change of base formula
When the logarithms are produced, truncate them to 3 decimal places.
Then prompt the user for a filename to use and write the table to that file.