Week 1: Quiz, 8/30
Improve the program RandomTest.java by making the following two
modifications to it.
- Make the program start by reading a single, positive integer; let us
call this n.
The program should use n instead of 10 everywhere.
In other words, the program should generate and count random numbers
between 0 and n - 1.
This change allows the user to easily run the program for various values of
n.
You could simply "cut-and-paste" code from ReadNumbers.java
to do this.
-
Simplify the program by calling the method nextInt instead of
nextDouble, to generate random numbers.
This simplification will get rid of the need to multiply the generated real
random number by 10 and then cast it into an integer.
You could consult the Random class
documentation, if necessary.
Final instructions:
- Submit the modified program RandomTest.java by the end of class time.
- Use the ICON dropbox for quiz1
- At the beginning of the program, as part of comments, please type your name and section.