Hi there,
I am supposed to make a Java programme called prize collection

My programme is a follow:

import javax.swing.JOptionPane;
import java.util.*;
import java.lang.*;


public class PrizeCollection {     
		       
       
public static void main (String[]args) {
	
		// Declare variables and arrays which will be used in the programme
 		String[] Name = new String [5];
        String[] Description = new String [5];
        String[] Color = new String [5];
        float[] Price = new float [5];

int option = 0;	
while (option!=4) //to exit the program when 4 is pressed
{
// create the main menu
option = Integer.parseInt(JOptionPane.showInputDialog("Please choose an option: \n"
                + "1 - Enter the details of a prize \n"
                + "2 - Print the details stored for all prizes \n"
                + "3 - Search for a prize with a particular value or by description \n"
                + "4 - Quit"));

// calling sub method to execute program when user choose an option
		if (option==1) 
			enterDetails(Name,Color,Description,Price);
        if (option==2) 
        	printDetails(Name,Color,Description,Price);
        if (option==3) 
        	searchDetails(Name,Color,Description,Price);
        
}

System.exit(0);
} // end the main method

// start sub method



public static void enterDetails(String Name[], String Color[], String Description[], float Price[]){
for (int i=0; i<5; i++)
       Name[i] = JOptionPane.showInputDialog(null, "Please enter the name of the prize: ");
       Color[i] = JOptionPane.showInputDialog(null, "Please enter the color of the prize: ");
       Description[i] = JOptionPane.showInputDialog(null, "Please enter the description of the prize: ");
       Price[i] = JOptionPane.showInputDialog(null, "Please enter the value of the prize: ");
        
    }


 // method to search
 public static void searchDetails(String Name[], String Color[], String Description[], float Price[])
 {
 	String search_a_prize = JOptionPane.showInputDialog("Please enter the name of the prize you want to search for");

 	boolean if_a_prize_is_found = false; // the boolean is initialize from false
 //loop start here
 for (int i=0; i<Type.length; i++) 

 {
 if (Name[i].equals (search_a_prize)) 
 {
 System.out.println("Successful search! A prize is found");
 System.out.println("The prize is: " + Name[i] + "\t\t\t Descption: " + Description[i] + "\t\t\t Color: " + Color[i] + "\t\t\t Price: " + Price[i]);

 if_a_prize_is_found = true; // then is this case the program will go to the next step
 }
 } // loop end here
 
 
 
  if (if_a_prize_is_found == false)
  System.out.println("No prize has been found!");

  }//end of search method

 // method to show the list 
 public static void printDetails(String Name[], String Color[], String Description[], float Price[]) // those refer to 1 in the daclaring variables
 {
 for (int i=0; i<Type.length; i++) 
 {
 System.out.println(Name[i] + " " + Description[i] + " " + Color[i] + " " + Price[i]); // will print the list
 } // end of loop
 } // end of method

 //method to exit the program

 public static void Exit()
 {
 	System.exit(0);
 }
} //end the program

Edited 5 Years Ago by peter_budo: Keep It Clean - Do use code tags when posting any code

You forget to ask a question.
If there are error messages, please copy and paste the FULL text here.
Are you having problems?
What does the program do and what do you want it to do differently?

Version A: must include the following:
 Separate arrays to store individual details of each item
 searching method
 useful comments, good indentation, good use of variable names

Requirements
• Display a menu of options (as below) to allow a user to manipulate three arrays which together represent prizes in a programming competition, until quit is selected.
o Enter details of a prize ( user is requested to enter the details of a prize from the keyboard)
o Print the details stored for all prizes
o Search for a prize with a particular value OR by description
o Quit
• Three arrays to represent details relating to a prizes.
 Declaration and initialisation of variables.
 Separate arrays to store individual details of each prize. A prize requires storage of :
• A description
• colour
• value of prize
 A menu of options dependent on an integer variable
• The facility to display how many prize details are stored in the arrays.
• The facility to request and accept input of a prize, and store in the next empty array elements.
• A facility to print the details of all prizes stored in the arrays.
• A search method to allow searching for a prize (with a particular value OR by description).

You posted the contents of your assignment.
Now what problems are you having? Please ask specific questions.
Or post error messages you don't know how to fix.

Sorry I'm just new at this. The errors that I receive are as follow:

--------------------Configuration: <Default>--------------------
C:\Users\Corinne\Documents\PrizeCollection.java:61: error: illegal start of expression
public static void searchDetails(String Name[], String Color[], String Description[], int Price[])
^
C:\Users\Corinne\Documents\PrizeCollection.java:61: error: illegal start of expression
public static void searchDetails(String Name[], String Color[], String Description[], int Price[])
^
C:\Users\Corinne\Documents\PrizeCollection.java:61: error: ';' expected
public static void searchDetails(String Name[], String Color[], String Description[], int Price[])
^
C:\Users\Corinne\Documents\PrizeCollection.java:61: error: ')' expected
public static void searchDetails(String Name[], String Color[], String Description[], int Price[])
^
C:\Users\Corinne\Documents\PrizeCollection.java:61: error: illegal start of expression
public static void searchDetails(String Name[], String Color[], String Description[], int Price[])
^
C:\Users\Corinne\Documents\PrizeCollection.java:61: error: ';' expected
public static void searchDetails(String Name[], String Color[], String Description[], int Price[])
^
C:\Users\Corinne\Documents\PrizeCollection.java:61: error: illegal start of expression
public static void searchDetails(String Name[], String Color[], String Description[], int Price[])
^
C:\Users\Corinne\Documents\PrizeCollection.java:61: error: ';' expected
public static void searchDetails(String Name[], String Color[], String Description[], int Price[])
^
C:\Users\Corinne\Documents\PrizeCollection.java:61: error: not a statement
public static void searchDetails(String Name[], String Color[], String Description[], int Price[])
^
C:\Users\Corinne\Documents\PrizeCollection.java:61: error: ';' expected
public static void searchDetails(String Name[], String Color[], String Description[], int Price[])
^
C:\Users\Corinne\Documents\PrizeCollection.java:61: error: <identifier> expected
public static void searchDetails(String Name[], String Color[], String Description[], int Price[])
^
C:\Users\Corinne\Documents\PrizeCollection.java:61: error: not a statement

public static void searchDetails(String Name[], String Color[], String Description[], int Price[])
^
C:\Users\Corinne\Documents\PrizeCollection.java:61: error: ';' expected
public static void searchDetails(String Name[], String Color[], String Description[], int Price[])
^
C:\Users\Corinne\Documents\PrizeCollection.java:84: error: illegal start of expression
public static void printDetails(String Name[], String Color[], String Description[], int Price[]) // those refer to 1 in the daclaring variables
^
C:\Users\Corinne\Documents\PrizeCollection.java:84: error: illegal start of expression
public static void printDetails(String Name[], String Color[], String Description[], int Price[]) // those refer to 1 in the daclaring variables
^
C:\Users\Corinne\Documents\PrizeCollection.java:84: error: ';' expected
public static void printDetails(String Name[], String Color[], String Description[], int Price[]) // those refer to 1 in the daclaring variables
^
C:\Users\Corinne\Documents\PrizeCollection.java:84: error: ')' expected
public static void printDetails(String Name[], String Color[], String Description[], int Price[]) // those refer to 1 in the daclaring variables
^
C:\Users\Corinne\Documents\PrizeCollection.java:84: error: illegal start of expression
public static void printDetails(String Name[], String Color[], String Description[], int Price[]) // those refer to 1 in the daclaring variables
^
C:\Users\Corinne\Documents\PrizeCollection.java:84: error: ';' expected
public static void printDetails(String Name[], String Color[], String Description[], int Price[]) // those refer to 1 in the daclaring variables
^
C:\Users\Corinne\Documents\PrizeCollection.java:84: error: illegal start of expression
public static void printDetails(String Name[], String Color[], String Description[], int Price[]) // those refer to 1 in the daclaring variables
^
C:\Users\Corinne\Documents\PrizeCollection.java:84: error: ';' expected
public static void printDetails(String Name[], String Color[], String Description[], int Price[]) // those refer to 1 in the daclaring variables
^
C:\Users\Corinne\Documents\PrizeCollection.java:84: error: not a statement
public static void printDetails(String Name[], String Color[], String Description[], int Price[]) // those refer to 1 in the daclaring variables
^
C:\Users\Corinne\Documents\PrizeCollection.java:84: error: ';' expected
public static void printDetails(String Name[], String Color[], String Description[], int Price[]) // those refer to 1 in the daclaring variables
^
C:\Users\Corinne\Documents\PrizeCollection.java:84: error: <identifier> expected
public static void printDetails(String Name[], String Color[], String Description[], int Price[]) // those refer to 1 in the daclaring variables
^
C:\Users\Corinne\Documents\PrizeCollection.java:84: error: not a statement
public static void printDetails(String Name[], String Color[], String Description[], int Price[]) // those refer to 1 in the daclaring variables
^
C:\Users\Corinne\Documents\PrizeCollection.java:84: error: ';' expected
public static void printDetails(String Name[], String Color[], String Description[], int Price[]) // those refer to 1 in the daclaring variables
^
C:\Users\Corinne\Documents\PrizeCollection.java:95: error: illegal start of expression
public static void Exit()
^
C:\Users\Corinne\Documents\PrizeCollection.java:95: error: illegal start of expression
public static void Exit()
^
C:\Users\Corinne\Documents\PrizeCollection.java:95: error: ';' expected
public static void Exit()
^
C:\Users\Corinne\Documents\PrizeCollection.java:95: error: ';' expected
public static void Exit()
^
C:\Users\Corinne\Documents\PrizeCollection.java:99: error: reached end of file while parsing
} //end the program
^
31 errors

Process completed.

error: illegal start of expression

You probably have a mismatched pair of {}s. Scan your code to be sure that all the leading brackets { have a matching trailing bracket} where you want it to be.

Most IDEs and fancy editors have a feature that will find the matching bracket. Place the cursor on a bracket and press some keyboard buttons and it finds the matching bracket.

I really need more help as I've spent the day checking everything and I cannot find whatis wrong!

Do all of your {}s pair up?
Does your editor have a tool to help you?

Otherwise you could print out the program and use a pencil to draw lines to pair up the {}s. Start at an inner most nesting and work out.

One thing I see that could be a problem with your code is that your do NOT use {} with all of your loops and if statements. Your code is indented but it is NOT inside of {}s.

Thank you very much! I have printed the code and managed to see that some {} were not correctly matching. Also, I have corrected a few other things and now it is working. I will continue to improve the code.

This question has already been answered. Start a new discussion instead.