Question: CSCI 161 - Lab 7: Deeper Dives Objectives The objectives of this lab are to reinforce and help teach: file I/O, in particular file line

CSCI 161 - Lab 7: Deeper Dives

Objectives

The objectives of this lab are to reinforce and help teach:

file I/O, in particular file line counting and line-based and token-based processing

use of an array to hold double values

use of the arrays class

Overview

In this lab you will extend and change the program you developed in Lab 6 (here), this time, making your updated program additionally print out the scores of the top 3 dives (the three dives with the highest overall scores).

Your updated program must use an array of doubles to hold the overall scores of each dive. In order to dimension your array, your program will first need to know the number of elements in the array (which is the number of lines in the DiveData.txt file).

Your updated program should use whatever means you desire to figure out the top three scores of all the dives as stored in the array you have added to your program. Please note that the Arrays(plural) class and its .sort() method will likely come in handy for that purpose.

Other than the updates described above, your program should adhere to the original specification in the assignment writeup. Below are updated input and output specifications for your consideration and use.

Instructions

Following are the instructions and you should follow them carefully:

Using Eclipse create a new Java Project and name it: Lab6

As with all your labs and assignments, add a class of the same name, Lab6, and include in that class a main method.

Your program should be based on (start with the code from) your Lab5 submission (see the "Overview" section above). If you did not properly complete Lab5, here is a solution.

Your program must read a file according to the "Input Specification" below.

Your program must output according to the "Output Specification" below.

Hint: Your program will need to know how many lines are in the DiveData.txt file in order to size the double array accordingly when it is declared. For this, I suggest a method that is passed in the filename, returns an integer which is the number of lines of the file, and within the method declares a file scanner to read the file one line at a time while counting the lines within.

Iteratively develop the assignment (get the original version working, test it, add code to one method, test, fix if needed, continue).

When the assignment is complete and working submit it as Lab7

Input Specification

Your program will once again read the DiveData.txt file from the current directory. The format of each line of the file is the same as the original specification. Your program can safely assume there will be at least three (3) lines of data in the file, but there could be any number.

For example, the following lines contain data for eight (8) dives:

 1 3.5 5.5 6.0 7.0 6.5 6.5 5.5 7.5 2 2.0 8.0 8.5 8.5 9.0 8.0 8.5 8.0 3 3.5 6.5 7.5 8.0 6.5 7.0 6.5 7.5 4 3.0 5.5 6.5 8.5 6.0 6.0 5.5 6.0 5 3.5 5.0 7.5 9.0 7.0 5.0 4.5 5.0 6 4.0 7.5 8.0 9.5 8.5 6.5 5.5 8.5 7 3.5 6.5 9.0 8.5 8.0 7.5 6.5 9.0 8 2.5 7.0 6.5 7.5 7.0 8.0 6.5 7.0 

Output Specification

Output an introductory message and then the scores for each dive.

Your program should output precisely according to the format below (wording, spacing, punctuation, precision of doubles, etc).

 Welcome to the Diver Scoring program. This program will calculate an overall score for a diver, based on individual dives. The diver's score for dive 1 is 66.15. The diver's score for dive 2 is 49.80. The diver's score for dive 3 is 73.50. The diver's score for dive 4 is 54.00. The diver's score for dive 5 is 61.95. The diver's score for dive 6 is 93.60. The diver's score for dive 7 is 82.95. The diver's score for dive 8 is 52.50. The average score for these dives is 66.81. The top three scores are: 93.60, 82.95, and 73.50. 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!