CSCI 255 — Programming Executions

This lab gives an example of the iterative program expertise appropriate for this course.

Getting started

Start up NetBeans and create a project for a Java Application. Use the names of your choice.

Delete the default main method and replace it with the following:

    public static void main(String[] args) {
        java.util.Random g = new java.util.Random() ;
        int X[] = new int[1000 + g.nextInt(10)] ;
        for (int i = 0; i<X.length; ++i) {
            X[i] = g.nextInt(10) ;
        }
        System.out.println(exceeds(X, 3)) ;
        System.out.println(exceeds(X, 7)) ;
        System.out.println(exceeds(new int[]{}, 2014)) ;
     }

Writing the missing method

This program is missing the exceeds method. A correct exceeds method takes two arguments. The first is an array of integers, and the second is an integer. The exceeds method returns the number of elements in the array that are greater than the second argument.

When run, this problem should print three numbers. The first should be close to 600, the second should be close to 200, and the third should be 0.

Show the lab instructor the result of your program’s execution.