Skip to main content.

Assignment 7: Streams Practice

Objective: To get experience using streams and parsing files in Java

Due: Before class on Wednesday

Using Streams

Overview: Modify your Olympic Score program so that the difficulty score and execution scores come from the user.

Set up

Create a new Eclipse project for this assignment. Copy your OlympicScores.java file into this project's src directory.

Using Scanner

From the user (the console), find out what the difficulty score is and the name of the file that contains the judges' execution scores. (Reminder: Look at the API for Scanner.) To simplify the program, you can assume a directory where the files are so that the user just has to enter the file name and not the whole directory.

Parsing the Execution Scores from a File

Parse the execution scores from the file. Your program should handle if there are less than 6 scores in the file appropriately. (Are there any other error cases that your program should handle?)

Example File: scores.dat

In Eclipse, the file should be at the project level, not at the src level.

Example Output:

What is the gymnast's average difficulty score? 8.525
What file contains the gymnast's excecution scores? scores.dat
Gymnastics Score
----------------
        Judges Execution Scores: 8.0 8.3 8.4 8.7 8.7 9.2 
        Average Execution Score: 8.525
        Average Difficulty Score: 8.525
        The Final Score: 17.05

Save the output from several runs of the program in a file called scores.out

Reminder: Style, Code Organization, and Usability

Use methods as appropriate to organize your code and make sure you code is user-friendly (e.g., helpful error messages). Provide comments for your methods.

Turnin

Make a jar file out of your project (which should include your input files, output file, and source code) called assign7.jar, saved in your cs209 directory. Submit your jar file using the command submitJar.sh assign7 Refer to Assignment 6 if you need reminders about how to use Eclipse to copy your code.

Grading (100 pts)

You will be evaluated based on the following criteria: