I've been given a coding problem that I'm having trouble with. I've been given the code below along with a text file. The text file contains the folowing:
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
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<9; l++) { //System.out.println("The data from line " + l); str = infile.next(); System.out.print(str + " "); str = infile.next(); System.out.print(str + " "); //I know there are 8 scores per diver for(int s=0; s<8; s++) { score = infile.nextDouble(); System.out.print(score + " "); } System.out.println(); } } }
I've been given the following instructions along with this... to be honest I'm not even really sure as to what is being asked of me:
Per the following UML diagram you are to write a Diver class. Then using the attached data file I want another program that reads the data processing one line at a time to instantiate your Diver class, populate the Diver's data attributes, and then outputting that Diver's information by calling it's toString method.
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 diver output the diver's name and 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.
I'm just wondering what exactly I should be doing for this code, and how I should go about completing it. I've never been this lost on any of the programs I've dont before. Help is greatly appreciated.