We help IT Professionals succeed at work.
Get Started

Printing from various methods.

Sdot718
Sdot718 asked
on
229 Views
Last Modified: 2012-05-11
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

Comment
Watch Question
Awarded 2011
Awarded 2011
Commented:
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE