0. Executive Summary

This is the first graded lab for CS2102. You will be graded by your ability to make progress on the primary task.

1. Stated Aims

  1. Develop experience using the java.util.Scanner class
  2. Learn how to apply loops.
  3. Understand how to read from the keyboard information that has structure
  4. Understand the nature of nested loops.

2. Background knowledge

  1. Understand arrays
  2. Understand Java for loop
  3. Understand how to read input from the command line
  4. Understand how to output to the screen using System.out.println

3. Setup

If you are in the Lab, perform the routine KH 202 setup or AK 120D setup; for now, ignore the "advanced setup" options. If you would like to set up  Eclipse on your personal computer, then (a) install Java JDK 1.5 if you need to as described in tools section (here); and (b) install Eclipse as described in tools section (here).

4. Primary Task

Design a program where the user enters a number n (which must be > 3) that determines the number of integers in a set that will be entered, one per line. Because the user is entering in a set, you can be assured that all numbers will be distinct. Your program must then read in n numbers from the keyboard and print out the average of the n-2 numbers that remain when you ignore the highest and the lowest numbers from the set.

4.1 Sample Program Run

Enter the size of the set?
7
Now enter the 7 numbers, one per line
8
2
9
13
90
15
7
The average of these numbers after removing the high value (90) and the low value (2) is 10.4

4.2. Design Recipe

Review the design recipe we have been following. Design questions to be answered in Lab and handed in

Note: do not go out of your way to describe every possible form of input. If you only considered one form, then state that. Don't invent spurious alternatives that were never really taken seriously.

5. Primary Task

Create a class Lab1 in the package defined by your CCC unix name.

6. Hint

Given a scanner constructed from System.in, you can read the next integer simply by invoking the nextInt() method call. Refer to the class examples, and the book (Section 2.2, pp. 78)

7. Turnin

Your goal is to turnin the assignment file (Lab1.java) by November 1st  at 11:59 PM. The name of the assignment you should use is "lab1".

Change History

Date Reason/Change
10/16/06 Initial Page