troubleshooting Question

Printing from various methods.

Avatar of Sdot718
Sdot718 asked on
Java
9 Comments1 Solution232 ViewsLast Modified:
When I try to combine the data collected through my two methods and print through main the data ends up null or all zeros.

(1)How do I get  the data collected from the methods to print through main so it can be as such
 Name  -- Score

(2)Also, how can I clear up the System.out prints of sums to have it looped to each Sum Array (Sum 1 through Sum9).  
import java.io.*;
import java.util.*;
import java.lang.*;



public class Assignment10
{
	public static double lowestScore = Double.MAX_VALUE;
	public static double highestScore = Double.MIN_VALUE;
	static String[] names = new String[9];



	public static void getName() throws FileNotFoundException

	{
		Scanner inFile = new Scanner(new FileReader("data.txt"));

		for(int i = 0; i < names.length; i++)
	{
			names[i] = inFile.next() + " " + inFile.next();
			inFile.nextLine();

		}
	System.out.print(Arrays.toString(names));



    }

	public static  void getScore() throws FileNotFoundException

	{
		Scanner inFile = new Scanner(new FileReader("diving_data.txt"));
		double[] scores = new double[72];

		Double total = 0.00;
		Double Sum1, Sum2, Sum3, Sum4, Sum5, Sum6, Sum7, Sum8, Sum9;
		  int index = 0;



			while(inFile.hasNext()) {
			    if(inFile.hasNextDouble()) {
				scores[index++] = inFile.nextDouble();
			    }
			    else {
				inFile.next();
			    }
			}

Sum1 = scores[0] + scores[1] + scores[4] + scores[5] + scores[6] + scores[7];
Sum2 = scores[8] + scores[9] + scores[11] + scores[12] + scores[13] + scores[14];
Sum3 = scores[16] + scores[17] + scores[20] + scores[21] + scores[22] + scores[23];
Sum4 = scores[24] + scores[25] + scores[26] + scores[28] + scores[29] + scores[30];
Sum5 = scores[32] + scores[33] + scores[35] + scores[36] + scores[37] + scores[38];
Sum6 = scores[40] + scores[41] + scores[42] + scores[43] + scores[45] + scores[46];
Sum7 = scores[48] + scores[49] + scores[52] + scores[53] + scores[54] + scores[55];
Sum8 = scores[56] + scores[58] + scores[59] + scores[60] + scores[61] + scores[62];
Sum9 = scores[66] + scores[67] + scores[68] + scores[69] + scores[70] + scores[71];

System.out.println(Sum1); // test

}
	public static void main(String[] args) throws FileNotFoundException
	{

		getScore();
		getName();


}

}

Open in new window

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros