Question: PLEASE HELP, Java question. I posted this question before and had no reply. Attached Files: diving_data.txt (411 B) Chen Ruolin 9.2 9.3 9 9.9 9.5
PLEASE HELP, Java question. I posted this question before and had no reply.
Attached Files:
diving_data.txt (411 B)
Chen Ruolin 9.2 9.3 9 9.9 9.5 9.5 9.6 9.8 Emilie Heymans 9.2 9.2 9 9.9 9.5 9.5 9.7 9.6 Wang Xin 9.2 9.2 9.1 9.9 9.5 9.6 9.4 9.8 Paola Espinosa 9.2 9.3 9.2 9 9.5 9.3 9.6 9.8 Tatiana Ortiz 9.2 9.3 9 9.4 9.1 9.5 9.6 9.8 Melissa Wu 9.2 9.3 9.3 9.7 9.2 9.2 9.6 9.8 Marie-Eve Marleau 9.2 9.2 9.2 9.9 9.5 9.2 9.3 9.8 Tonia Couch 9.2 9 9.1 9.5 9.2 9.3 9.4 9.6 Laura Wilkinson 9.7 9.1 9.3 9.4 9.5 9.4 9.6 9.2
readFile.java (722 B)
import java.io.*; import java.util.*; public class readFile { static Scanner infile = null; public static void main(String[] args) throws IOException { infile = new Scanner(new FileReader("diving_data.txt")); String str = null; double score = 0.0; //I know there are 9 lines of data for(int l=0; l NOTE: The difference between this assignment 11 and assignment 10:
This version requires the Diver class/object and the Diver object instances (1/Diver) will contain the data pertaining to each Diver and their respective scores!
Create a Diver java class per the following Diver uml diagram:
In a diving competition, each contestant's score is calculated by dropping the lowest and highest scores and then adding the remaining scores. Write a program that reads the provided data file formatted as depicted in the following table. For each row of data create an instance of a Diver object from that row of data. Output each diver's name, all of her scores and a total score using the above scoring rules. Format each diver's total score to two decimal places. So for example, the output for Chen Ruolin below would be: Chen Ruolin 56.90 points.
| Diver | Score 1 | Score 2 | Score 3 | Score 4 | Score 5 | Score 6 | Score 7 | Score 8 |
| Chen Ruolin | 9.2 | 9.3 | 9 | 9.9 | 9.5 | 9.5 | 9.6 | 9.8 |
| Emilie Heymans | 9.2 | 9.2 | 9 | 9.9 | 9.5 | 9.5 | 9.7 | 9.6 |
| Wang Xin | 9.2 | 9.2 | 9.1 | 9.9 | 9.5 | 9.6 | 9.4 | 9.8 |
| Paola Espinosa | 9.2 | 9.3 | 9.2 | 9 | 9.5 | 9.3 | 9.6 | 9.8 |
| Tatiana Ortiz | 9.2 | 9.3 | 9 | 9.4 | 9.1 | 9.5 | 9.6 | 9.8 |
| Melissa Wu | 9.2 | 9.3 | 9.3 | 9.7 | 9.2 | 9.2 | 9.6 | 9.8 |
| Marie-Eve Marleau | 9.2 | 9.2 | 9.2 | 9.9 | 9.5 | 9.2 | 9.3 | 9.8 |
| Tonia Couch | 9.2 | 9 | 9.1 | 9.5 | 9.2 | 9.3 | 9.4 | 9.6 |
| Laura Wilkinson | 9.7 | 9.1 | 9.3 | 9.4 | 9.5 | 9.4 | 9.6 | 9.2 |
Your program must read the data in from the provided data file, the attached ReadFile.java file shows the logic for reading each row of data. Once all the data has been read and the Diver instances created (and saved). Output each Diver's name, all her scores and the calculated total score for that Diver. Where total points is calculated based on the scoring rule defined above.
A couple of points regarding the above uml diagram:
addScore(double pScr) // is a convenience method that adds a single score to the scores ArrayList as a time.
calculateTotalScore() //is another convenience method that calculates a Diver's total score according to the rules below regarding how the total score is arrived at.
toString() //build's a string consisting of the Diver's first and last name and all the Diver's individual scores contained in the scores ArrayList and the Diver's resulting total score.
Either a main method may be added to the Diver class for testing or a separate program may be written. As a row of data is read an Instance of a Diver object needs to be created, it's data fields populated and the Diver object needs to be added to a separate ArrayList. For each Diver output the diver's name and total score using the provided scoring rules. Each contestant's score is calculated by dropping the lowest and highest scores and then adding the remaining scores. Format each diver's total score to two decimal places. So for example, the output for Chen Ruolin below would be: Chen Ruolin 56.90 points.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
