Random number generation and statistics


Follow the directions in the TODO statements of RandomGenerator.java:

public class RandomGenerator {

    public static void main(String[] args) {
        //TODO: Create a Scanner object to read keyboard input.
        //TODO: Ask the user a lower and upper bound.
        //TODO: Ask the user for the number of random integers to generate.
        //TODO: Generate random integers of the desired length and bound.
        //TODO: Print the average, max, min, count, and sum of the integers.

Submit your altered RandomGenerator.java file.


Have a look at the slides for the list of methods that generate streams of random numbers. The IntStream.summaryStatistics() method may be useful.

This material was created by Raffi Khatchadourian and published freely under a Creative Commons Attribution 4.0 license.