<< Return to Homework Page

Lab 4 : Do You Know The Score?

Lab Overview

Getting Started

In this lab we'll finally start writing Java code, and to do that we'll need the Eclipse editor. You can certainly write Java code with other programs, but Eclipse is what we'll be using for this course. If you haven't gotten Eclipse working before (or if you're uncertain of how to use it) first follow these start-up directions to see how to get started with Eclipse. Even if you are comfortable using Eclipse, be sure to download the cs1.jar file so that your programs can read input from their user (probably you) as well as output information. Instructions for what to do with that file are given in the start-up directions linked above.

This Lab

Given a set of scores. It's common to want to calculate the average score and highest score from that group. In this lab, we're creating a program to do just that. The program will first ask the user (the person using the program) how many integer numbers he/she wishes to average. The program will then take in that many integer numbers, one at a time, each time giving the user how many numbers have been taken in so far. Finally, after all numbers have been entered the program will display the average of those numbers AND also display the largest number from the set of numbers entered.

For an added twist, after handling the scores and returning an answer, the program should ask the user if he/she wishes to run the program again (to potentially run on a different set of scores). The program will then continue to loop as long as the user responds with the string "yes".

To complete this assignment you'll only need the basic Java components we've seen so far in class:

When approaching this problem, start simple. First try the Eclipse start-up directions or just get a simple program running that prints out some text (like "Hello Earth"). Then get a simple program running that gets a for-loop to work by itself (and, for example, run for exactly 10 iterations). Then try getting a while or do-while loop to run by itself. This will allow you to make sure that you know how these program statements should work before you try them as part of a larger program.

When you start working on this actual assignment, break that up into steps as well. Maybe you'll first just get the program to take information from the user and then echo it back to the user. Then perhaps get the program to loop as long as the user enters the text "yes". Then finally try taking in numbers and as a last step averaging them and returning the highest among them.

In class I'll demo my example program so you can see what it will look like. Also, here's a screenshot of what the example program's output looked like.

Program Requirements

What To Turn In