Hi, just wondered if anyone could help, this is my college work an i have this bit of code, just wondered if anyone could help me.....

im trying to do an addition of 3 array amounts


	public void AverageProduction()
	{
		/*Shows input dialog box asking for user to enter a name
		String value declared for user input storeage*/
		String category = JOptionPane.showInputDialog( "Please enter a Cider name so we can work out its average production " );
		
		/*If statement used to return program to main start menu if cancel button is pressed*/	
		if(category==null)
		{
			Startmenu();/*Instruction to return to start menu*/
		}
		
		/*Debug line for data search.Displayed on system.out.println */
		//System.out.println("The average is: ");
		
		/*for loop used to search array index for the name entered by user
		int a = storage for number of the counter for name array row
		(counter for row number; while row number doesn't equal any of the Strings in the array row; add to counter to search again on next row )*/ 
			for(int a =0;a<name.length;a++)/**/
			{	
				
				/*If statement used to compare string array index storing peoples names equal(ignoring case of lettering) to input entered by the user*/
				if (name[a][0].equalsIgnoreCase(category)) 
				{
					/*If the if statement is true
					
					Debug line for data search.Displays results on system.out.println */		
					System.out.println("\t\t\t\t "+name[a][0]+ " \t "+name[a][1] +"\n"+weight[a][2]);		
					
					/*Shows user results in a message dialog box, displaying search row number of array String information(name and category group)*/
				//	JOptionPane.showMessageDialog(null,"The category group for:\n" +weight[a][0] +"\n"+weight[a][1] +"\n"+weight[a][2]);

					/*Shows user results in a message dialog box, Average*/
					[B][U]JOptionPane.showMessageDialog(null,"The total average is " +weight[a][0] +" + "+weight[a][1] +" + "+weight[a][2]);[/U][/B]
					
					/*Instruction to return to the beginning of method for finding category results once results have been displayed*/
					AverageProduction();
				}
			}
			/*Debug line to display error on system.out.println*/
			System.out.println(" "+ error+"\nSorry the name you entered didn't match any on file.\n"+ "Please ensure it is spelt correctly");
			
			/*Shows user message dialog box to display error*/
			JOptionPane.showMessageDialog(null," Sorry the name you entered didn't match any on file.\n" + "Please ensure it is spelt correctly"
			,"Incorrect Data",JOptionPane.ERROR_MESSAGE);
			
			/*Instruction to return to the beginning of method for finding category results once error result has been displayed*/
			AverageProduction();
			
	}


How can i get this to work? thanks :) xx
Obviously there is more code that contains my arrays, might be better to send this to someone if anyone could help me??
/*Imports Java library files*/
import javax.swing.JOptionPane;
import java.text.*;

/*Filename for programs class*/
class Cider
	{
		/*Global variables declared*/

		/*2D array storage of information on names and group category - stores 21 pieces of data in 2 rows*
		*Saved as a String value*/
		public String name [] [] = new String [24] [2];
		/*2D array storage of information on weights taken  - stores 21 weights in 3 year categories*
		*Saved as double variable value*/
		public double weight [] []= new double [24] [3];
		/*Global String variable to return results to two decimal places*/
		DecimalFormat twoPlaces = new DecimalFormat("#,##00.00");
		/*Global String variable to return message if user didn't complete the search*/
		String searchincomplete = "\t\t\t *** SEARCH WAS UNFINISHED ***  ";
		/*Global String variable to return error message if input was entered incorrectly*/
		String error = "\t\t\t***   ERROR   ***   INCORRECT INPUT   ***";
		
		/*Runs program- method*/
		public static void main(String[] args)
			{
						Cider optpane = new Cider();
			}
		/*Constructor*/
		public Cider()
		{
		
			/*2D Array index for storing 23 - String value */		
			name [0] [0] = "Gills Green Dry";
			name [1] [0] = "Venn Ditch";
			name [2] [0] = "Golford Rise";
			name [3] [0] = "Steaming Jess";
			name [4] [0] = "Merrifield Brook";
			name [5] [0] = "Waldron Beck";
			name [6] [0] = "Coombe Spring";
			name [7] [0] = "Abbey Press";
			name [8] [0] = "Long Barrow";
			name [9] [0] = "Halden Marsh";
			name [10] [0] = "Kerrygate Farm";
			name [11] [0] = "Rosers Plum";
			name [12] [0] = "Buxted Boiler";
			name [13] [0] = "Fiddlers Elbow";
			name [14] [0] = "Madley Wood";
			name [15] [0] = "Burnt Oak Root";
			name [16] [0] = "Wobbly Bottom";
			name [17] [0] = "Capton Acre";
			name [18] [0] = "Didley Furrow";
			name [19] [0] = "Appledore Dry";
			name [20] [0] = "Deep Part";
			name [21] [0] = "Coggins Mill";
			name [22] [0] = "Cockyard Fold";
			name [23] [0] = "Shirkoak Rosy";
			
			/*2D Array index for storing 23 - String value */
			name [0] [1] = "Kent";
			name [1] [1] = "Devon";
			name [2] [1] = "Kent";
			name [3] [1] = "Herefordshire";
			name [4] [1] = "Devon";
			name [5] [1] = "Sussex";
			name [6] [1] = "Devon";
			name [7] [1] = "Herefordshire";
			name [8] [1] = "Sussex";
			name [9] [1] = "Kent";
			name [10] [1] = "Herefordshire";
			name [11] [1] = "Sussex";
			name [12] [1] = "Sussex";
			name [13] [1] = "Devon";
			name [14] [1] = "Herefordshire";
			name [15] [1] = "Sussex";
			name [16] [1] = "Kent";
			name [17] [1] = "Devon";
			name [18] [1] = "Herefordshire";
			name [19] [1] = "Kent";
			name [20] [1] = "Devon";
			name [20] [1] = "Sussex";
			name [20] [1] = "Herefordshire";
			name [20] [1] = "Kent";

			/*2D Array index for storing 23  - Stored as a double variable - decimal */	
			weight [0] [0] = 158.2;
			weight [1] [0] = 1042.2;
			weight [2] [0] = 596.0;
			weight [3] [0] = 514.1;
			weight [4] [0] = 792.1;
			weight [5] [0] = 2022.3;
			weight [6] [0] = 1192.0;
			weight [7] [0] = 405.6;
			weight [8] [0] = 527.4;
			weight [9] [0] = 892.1;
			weight [10] [0] = 748.7;
			weight [11] [0] = 4405.6;
			weight [12] [0] = 98.6;
			weight [13] [0] = 4086.5;
			weight [14] [0] = 3089.4;
			weight [15] [0] = 45.3;
			weight [16] [0] = 856.2;
			weight [17] [0] = 687.5;
			weight [18] [0] = 1568.7;
			weight [19] [0] = 3041.0;
			weight [20] [0] = 2255.7;
			weight [21] [0] = 589.1;
			weight [22] [0] = 2002.3;
			weight [23] [0] = 2897.6;
			
			/*2D Array index for storing 23  - Stored as a double variable- decimal */	
			weight [0] [1] = 195.6;
			weight [1] [1] = 987.6;
			weight [2] [1] = 609.1;
			weight [3] [1] = 528.6;
			weight [4] [1] = 784.5;
			weight [5] [1] = 2589.3;
			weight [6] [1] = 1006.7;
			weight [7] [1] = 455.4;
			weight [8] [1] = 500.6;
			weight [9] [1] = 903.1;
			weight [10] [1] = 782.6;
			weight [11] [1] = 2581.2;
			weight [12] [1] = 102.4;
			weight [13] [1] = 3932.7;
			weight [14] [1] = 2579.5;
			weight [15] [1] = 56.1;
			weight [16] [1] = 958.7;
			weight [17] [1] = 692.5;
			weight [18] [1] = 1682.4;
			weight [19] [1] = 2986.4;
			weight [20] [1] = 4884.6;
			weight [21] [1] = 527.6;
			weight [22] [1] = 2524.7;
			weight [23] [1] = 156.2;
	
			/*2D Array index for storing 23  - Stored as a double variable - decimal */	
			weight [0] [2] = 192.4;
			weight [1] [2] = 1102.4;
			weight [2] [2] = 611.7;
			weight [3] [2] = 545.6;
			weight [4] [2] = 776.4;
			weight [5] [2] = 2214.6;
			weight [6] [2] = 1206.7;
			weight [7] [2] = 460.2;
			weight [8] [2] = 538.7;
			weight [9] [2] = 902.1;
			weight [10] [2] = 722.4;
			weight [11] [2] = 3781.4;
			weight [12] [2] = 100.00;
			weight [13] [2] = 3799.5;
			weight [14] [2] = 3802.1;
			weight [15] [2] = 55.4;
			weight [16] [2] = 1024.3;
			weight [17] [2] = 704.2;
			weight [18] [2] = 1654.2;
			weight [19] [2] = 3147.5;
			weight [20] [2] = 462.7;
			weight [21] [2] = 542.4;
			weight [22] [2] = 2558.6;
			weight [23] [2] = 1042.6;




			/*Instruction to begin start menu method*/
			Startmenu();
		}	
	/*Method for main start menu*/		
	public void Startmenu()
	{
		/*Booleen statement to keep program running so long as an input is selected*/
		while (true)
		{
			/*String array value containing questions for the start menu*/
			String [] startquest = new String[]{"County for Cider entered","Which is a cider's average production?","Which is the highest producing cider at:","Which Cider produced above or below threshold","Which County had the best annual Production","Which year had the best production"};
		
			/*Object for start displaying questions from String values already declared. Displayed in JOptionPane */
			Object start = JOptionPane.showInputDialog(null,"What would you like to do?",
			"Bobble Bottles - Bethanie Caley",JOptionPane.QUESTION_MESSAGE,null, startquest,"Category of name entered"); 
		
			/*If statement used to close program if cancel button is pressed*/
			if (start==null)
			{
				System.exit(0);
			}
			/*Else if statement used to start method if start = String below*/
			else if (start.equals("County for Cider entered"))
			{
				CiderCounty(); /*Instruction to go to method for finding category results for a name entered*/  
			}

			else if (start.equals("Which is a cider's average production?"))
			{
				AverageProduction(); 
			}
		
			else if (start.equals("Which is the highest producing cider at:"))
			{
				HighestProducingCider(); 
			}

			else if (start.equals("Which Cider produced above or below threshold"))
			{
				AboveOrBelowThreshold(); 
			}

			else if (start.equals("Which County had the best annual Production"))
			{
				AnnualProduction();
			}

			else if (start.equals("Which year had the best production"))
			{
				BestProduction(); 
			}
		}
		
	}
	
//************************************/*Method for finding County group from a cider name*/*****************************************************//
	public void CiderCounty()
	{
		/*Shows input dialog box asking for user to enter a name
		String value declared for user input storeage*/
		String category = JOptionPane.showInputDialog( "Please enter a Cider name so we can\n locate their County it is from " );
		
		/*If statement used to return program to main start menu if cancel button is pressed*/	
		if(category==null)
		{
			Startmenu();/*Instruction to return to start menu*/
		}
		
		/*Debug line for data search.Displayed on system.out.println */
		System.out.println("The county is: ");
		
		/*for loop used to search array index for the name entered by user
		int a = storage for number of the counter for name array row
		(counter for row number; while row number doesn't equal any of the Strings in the array row; add to counter to search again on next row )*/ 
			for(int a =0;a<name.length;a++)/**/
			{	
				
				/*If statement used to compare string array index storing peoples names equal(ignoring case of lettering) to input entered by the user*/
				if (name[a][0].equalsIgnoreCase(category)) 
				{
					/*If the if statement is true
					
					Debug line for data search.Displays results on system.out.println */		
					System.out.println("\t\t\t\t "+name[a][0]+ " \t "+name[a][1]);		
					
					/*Shows user results in a message dialog box, displaying search row number of array String information(name and category group)*/
					JOptionPane.showMessageDialog(null,"The category group for:\n" +name[a][0] +"\n"+name[a][1]);
					
					/*Instruction to return to the beginning of method for finding category results once results have been displayed*/
					CiderCounty();
				}
			}
			/*Debug line to display error on system.out.println*/
			System.out.println(" "+ error+"\nSorry the name you entered didn't match any on file.\n"+ "Please ensure it is spelt correctly");
			
			/*Shows user message dialog box to display error*/
			JOptionPane.showMessageDialog(null," Sorry the name you entered didn't match any on file.\n" + "Please ensure it is spelt correctly"
			,"Incorrect Data",JOptionPane.ERROR_MESSAGE);
			
			/*Instruction to return to the beginning of method for finding category results once error result has been displayed*/
			CiderCounty();
			
	}
		
		
		
//********************************************END OF METHOD FOR FINDING County group from a cider name************************************************

	public void AverageProduction()
	{
		/*Shows input dialog box asking for user to enter a name
		String value declared for user input storeage*/
		String category = JOptionPane.showInputDialog( "Please enter a Cider name so we can work out its average production " );
		
		/*If statement used to return program to main start menu if cancel button is pressed*/	
		if(category==null)
		{
			Startmenu();/*Instruction to return to start menu*/
		}
		
		/*Debug line for data search.Displayed on system.out.println */
		//System.out.println("The average is: ");
		
		/*for loop used to search array index for the name entered by user
		int a = storage for number of the counter for name array row
		(counter for row number; while row number doesn't equal any of the Strings in the array row; add to counter to search again on next row )*/ 
			for(int a =0;a<name.length;a++)/**/
			{	
				
				/*If statement used to compare string array index storing peoples names equal(ignoring case of lettering) to input entered by the user*/
				if (name[a][0].equalsIgnoreCase(category)) 
				{
					/*If the if statement is true
					
					Debug line for data search.Displays results on system.out.println */		
					System.out.println("\t\t\t\t "+name[a][0]+ " \t "+name[a][1] +"\n"+weight[a][2]);		
					
					/*Shows user results in a message dialog box, displaying search row number of array String information(name and category group)*/
				//	JOptionPane.showMessageDialog(null,"The category group for:\n" +weight[a][0] +"\n"+weight[a][1] +"\n"+weight[a][2]);

					/*Shows user results in a message dialog box, Average*/
					JOptionPane.showMessageDialog(null,"The total average is " +weight[a][0] +" + "+weight[a][1] +" + "+weight[a][2]);
					
					/*Instruction to return to the beginning of method for finding category results once results have been displayed*/
					AverageProduction();
				}
			}
			/*Debug line to display error on system.out.println*/
			System.out.println(" "+ error+"\nSorry the name you entered didn't match any on file.\n"+ "Please ensure it is spelt correctly");
			
			/*Shows user message dialog box to display error*/
			JOptionPane.showMessageDialog(null," Sorry the name you entered didn't match any on file.\n" + "Please ensure it is spelt correctly"
			,"Incorrect Data",JOptionPane.ERROR_MESSAGE);
			
			/*Instruction to return to the beginning of method for finding category results once error result has been displayed*/
			AverageProduction();
			
	}

//********************************************************************************************

		public void HighestProducingCider()
	{
		/*Shows input dialog box asking for user to enter a Cider Name
		String value declared for user input storeage*/
		String County = JOptionPane.showInputDialog( "Please chose a year " );

			/*Debug line to display error on system.out.println*/
			System.out.println(" "+ error+"\nSorry the cider you entered didn't match any on file.\n"+ "Please ensure it is spelt correctly");
			
			/*Shows user message dialog box to display error*/
			JOptionPane.showMessageDialog(null," Sorry the cider you entered didn't match any on file.\n" + "Please ensure it is spelt correctly"
			,"Incorrect Data",JOptionPane.ERROR_MESSAGE);
			
			/*Return to the beginning of method*/
			CiderCounty();
			
	}

//********************************************************************************************

		public void AboveOrBelowThreshold()
	{
		/*Shows input dialog box asking for user to enter a Cider Name
		String value declared for user input storeage*/
		String County = JOptionPane.showInputDialog( "Please enter a Cider name to find out there average production " );

			/*Debug line to display error on system.out.println*/
			System.out.println(" "+ error+"\nSorry the cider you entered didn't match any on file.\n"+ "Please ensure it is spelt correctly");
			
			/*Shows user message dialog box to display error*/
			JOptionPane.showMessageDialog(null," Sorry the cider you entered didn't match any on file.\n" + "Please ensure it is spelt correctly"
			,"Incorrect Data",JOptionPane.ERROR_MESSAGE);
			
			/*Return to the beginning of method*/
			CiderCounty();
			
	}

//********************************************************************************************

		public void AnnualProduction()
	{
		/*Shows input dialog box asking for user to enter a Cider Name
		String value declared for user input storeage*/
		String County = JOptionPane.showInputDialog( "Please County had the best annual production " );

			/*Debug line to display error on system.out.println*/
			System.out.println(" "+ error+"\nSorry the cider you entered didn't match any on file.\n"+ "Please ensure it is spelt correctly");
			
			/*Shows user message dialog box to display error*/
			JOptionPane.showMessageDialog(null," Sorry the cider you entered didn't match any on file.\n" + "Please ensure it is spelt correctly"
			,"Incorrect Data",JOptionPane.ERROR_MESSAGE);
			
			/*Return to the beginning of method*/
			CiderCounty();
	}
//********************************************************************************************

		public void BestProduction()
	{
		/*Shows input dialog box asking for user to enter a Cider Name
		String value declared for user input storeage*/
		String County = JOptionPane.showInputDialog( "Please enter a county ");

		if(County==null)
		{
			Startmenu();/*Instruction to return to start menu*/
		}

		for(int a =0;a<name.length;a++)/**/
			{	
				
				/*If statement used to compare string array index storing peoples names equal(ignoring case of lettering) to input entered by the user*/
				if (name[a][0].equalsIgnoreCase(County)) 
				{
					/*If the if statement is true
					
					Debug line for data search.Displays results on system.out.println */		
					System.out.println("\t\t\t\t "+name[a][0]+ " \t "+name[a][1]);		
					
					/*Shows user results in a message dialog box, displaying search row number of array String information(name and category group)*/
					JOptionPane.showMessageDialog(null,"The category group for:\n" +name[a][0] +"\n"+name[a][1]);
					
					/*Instruction to return to the beginning of method for finding category results once results have been displayed*/
					CiderCounty();
				}
			}


			/*Debug line to display error on system.out.println*/
			System.out.println(" "+ error+"\nSorry the cider you entered didn't match any on file.\n"+ "Please ensure it is spelt correctly");
			
			/*Shows user message dialog box to display error*/
			JOptionPane.showMessageDialog(null," Sorry the cider you entered didn't match any on file.\n" + "Please ensure it is spelt correctly"
			,"Incorrect Data",JOptionPane.ERROR_MESSAGE);
			
			/*Return to the beginning of method*/
			CiderCounty();
	}
//********************************************************************************************

			

	/*
		public AssigmentNew()
	{
		//Defining my first variable - i created a double as it will contain a decimal point - gallons.pints
		double value = 0;
		//The enter function has been called to insert amount that you want converting
		value = enter();
		System.out.println(value);

		//Spltting the amount up that had been entered getting the first amount.
		int gallons = (int)(value);
		System.out.println("Gallons = "+gallons);

		//Splitting the amount given into pints
		int pints = (int)((value-gallons)*10);
		System.out.println("Pints = " +pints);

		//Multiplying the amount of gallons in to pints.
		int gallonsInToPints = gallons*8;
		System.out.println("Gallons in to pints = "+gallonsInToPints);

		//Adding the amounts of pints entered and the amount of gallons converted into pints together
		value = AddingBothAmountsTogether(gallonsInToPints, pints);
		System.out.println("Both values added together = "+value);

		//Calling the ConvertingToLitres function, where the total amount of pints has been multiplies by the conversion factor
		double litres = 0.5682625;		
		value = convertingToLitres(value, litres);
		System.out.println("Converted in to litres ="+ value);

		//Printing out the final amount of litres
		double Amount = value;
		FinalStep(Amount);
	
	private double enter()
	{
		//Here it is asking to enter an amount to convert, this will then return the amount when the enter function is being called
		return Double.parseDouble(JOptionPane.showInputDialog("Enter the amount of gallons.pints"));
	}

	private double AddingBothAmountsTogether(double first, double second)
	{
		//Adding both amount together so that its all converted into Pints
		return first + second;
	}

	private double convertingToLitres(double third, double fourth)
	{
		//Multiplying both amounts together to get the final amount of litres, using the conversion amount.
		return third * fourth;
	}

	public void FinalStep(double Amount)
	{
		JOptionPane.showMessageDialog(null,"Converted into litres = " + Amount);
	}

	*/


}

That is my full code, im trying to work out the average but first of all need to get the sum of the three amounts before i can dived by 3 to get an average?!  HELP PLEASE?!?!?
On any other ones i could do with help too  Thankyou x

So just add them. I don't understand what part you are having trouble with

double total = weight[a][0] +weight[a][1] +weight[a][2];

String concatenation has nothing at all to do with math operations on variables.

Sorry my mind went blank an i have been sat going over it all afternoon over a simple problem.

I don't suppose you have an idea as to how i could find out the highest year produced amount, this is my next question........they pick a year the first lot of data is 1995,2000 and 2005 the user needs to pick a year and show the highest produce from that year?

•	Which was the highest producing cider at <User Input – Year> and what was that production? 

Thanks muchly

Just loop through the array and have a variable that keeps track of the highest. If the current array element is greater than that value, set the value to that elements value.

Thanks alot i shall try :) i might pop back for help when im done if thats ok!
Thanks again

Just loop through the array and have a variable that keeps track of the highest. If the current array element is greater than that value, set the value to that elements value.

Help...how do i do this i am totally stuck, would you be able to show me?!?!  :S Please
Help...how do i do this i am totally stuck, would you be able to show me?!?!  :S Please

Here's a skeleton:

// array[] is an array of Integer.

int maxNumber = array[0]; // intialize to first element

for (int i = 1; i < array.length; i++)
{
    if (array[i] > maxNumber)
        maxNumber = array[i];
}

// maxNumber now holds maximum of array.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.