1 Replies - 2428 Views - Last Post: 24 November 2010 - 08:49 PM Rate Topic: -----

#1 jsc0290  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 24-November 10

parallel arrays .java help

Posted 24 November 2010 - 08:47 PM

import java.util.Scanner;

public class ParallelArrays
{
   public static void main(String[] args)
  {
	  String[] names = { "Doc", "Grumpy", "Happy",
					  "Sleepy", "Dopey", "Sneezy", "Bashful" };	
	  
	  System.out.println("The average of the scores is " + getAverage());
	  
	  System.out.println("Name : " + getNames() + "\tGrade: " + 
                         getScores() + "\tMean Deviation: " + getMean());	
	  
	  
   }
	
	private static String getNames()
	{
	String[] names = { "Doc", "Grumpy", "Happy",
					  "Sleepy", "Dopey", "Sneezy", "Bashful" };
	}
	
	private static double getScores()
	{
	final int NUM_STUDENTS = 7;
	double[] scores = new double[NUM_STUDENTS];
	double score = 0.0;
	
	Scanner keyboard = new Scanner(System.in);
	 
	 for (int i = 0; i <= 6 ; i++)
	 {
	  System.out.print("Enter " + getNames() + "'s score: ");
     scores[i] = keyboard.nextDouble();
	  score = scores[i];
	 }
	  return score;
	 }
	 
   private static double getAverage()
   {
   double average = 0.0;
   double total = 0.0;
   
   Scanner keyboard = new Scanner(System.in);
   
   for (int i = 0; i <= 6 ; i++) 
    {
	  total += getScores();
     average = total / 7;
	 }
	 return average;
   }
	
	private static double getMean()
   {
   double mean = 0.0;
	double average = 0.0;
	
   for (int i = 0; i <= 6; i++) 
		{
		mean = getScores() - getAverage();
		}
		return mean;
   }
}


I need help to figure out the program..

the program should print out what you see from a file which I attached.

thank you..

Attached image(s)

  • Attached Image

This post has been edited by macosxnerd101: 24 November 2010 - 08:48 PM
Reason for edit:: Please use code tags


Is This A Good Question/Topic? 0
  • +

Replies To: parallel arrays .java help

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10767
  • View blog
  • Posts: 40,090
  • Joined: 27-December 08

Re: parallel arrays .java help

Posted 24 November 2010 - 08:49 PM

Not good practice to use parallel arrays. Better to use classes and Objects instead. You should check out my tutorial Moving Away From Parallel Arrays, where I hit more on class design.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1