Ok, well Ive pretty much finished my program and now all thats left is this error that keeps coming up and I dont know how or where to fix it. The error comes up under the bracket. Iam guess Iam missing a bracket at the end, but when I put one there, then a lot of errors all over the code come up. Can anyone help?

Heres my code,

import java.util.*;

public class Sizes {

    public static void main(String[] args) { //This is where the error comes up, Under the bracket//


    public static void menu(Scanner kbd, int height, int weight, int age)
    {

    int choice=0, answer, Y, N;

    System.out.print("1. Calculate Hat Size");
    System.out.print("2. Calculate Jacket Size");
    System.out.print("3. Calculate Waist Size");
    System.out.print("4. No More Calculations");

    System.out.println("Make a choice:");
    choice = kbd.nextInt();

    if (choice == 1)
    {
        displayHat(weight, height);
    }

    else 
        if (choice == 2)
        {
            displayJacket(weight, height);
        }

    else
        if (choice == 3)
        {
            displayWaist(weight);
        }

        else 
            if (choice == 4)
            {
                System.out.println("Is there another person for which to calculate sizes?" + " " + "(Y/N)");
                answer = kbd.nextInt();

                if(answer == Y)
                {
                    menu(kbd, height, weight, age);
                }
                else
                    if (answer == N)
                    {
                        System.out.print("Thanks");
                    }
        }

    }

    public static void getData()
    {

        Scanner kbd = new Scanner(System.in);

        int height, weight, age;

        System.out.println("Enter your height (in inches):");
        height = kbd.nextInt();

        System.out.println("Enter your weight (in pounds):");
        weight = kbd.nextInt();

        System.out.println("Enter your age (in years):");
        age = kbd.nextInt();

        menu(kbd, height, weight, age);
    }

    public static double hatSize (int weight, int height)
    {
    return weight/height * 2.9;
    }

    public static void displayHat (int weight, int height)
    {
        System.out.println("Your hat size is: " + hatSize(weight,height));
    }

    public static double jacketSize (int weight, int height)
    {
    return weight * height / 288;;
    }


    public static void displayJacket (int weight, int height)
    {
        System.out.println("Your jacket size is: " + jacketSize(weight,height));
    }


    public static double waistSize (int weight)
    {   
        return weight / 5.7;;
    }

    public static void displayWaist (int weight)
    {
        System.out.println("Your jacket size is: " + waistSize(weight));
    }

    }

P.S. Iam sorry I havent put any code-tags. I dont know how.

[ code ] and [ /code ] (without spaces)

its very unreadable without tags, exspecially since there is so much

public static void main(String[] args) { //This is where the error comes up, Under the bracket//

} //where the missing bracket should be (assuming you even want your main method)

public static void menu(Scanner kbd, int height, int weight, int age)
{
    //a very large method
}

//} an error causing bracked, as menu() is enclosed in a method

your problem is you are opening the main method , but never closing it

if you put a } at the end, then the menu method is enclosed in the main method, and so it produces an error

Oh wow, thanks.

But now when I try to run it, nothing comes up. Why wont it work?

If you have problems like this, best thing to do is avoid them!
I can't tell from your post but having proper indentation is a life saver when you have an error such as yours, especially if you are working with a lot of code.

Oh wow, thanks.

But now when I try to run it, nothing comes up. Why wont it work?

Because you more than likely don't have anything in your main method after closing the brace.

yep, assuming you close the brace, or deleted the main method you now have a program that does nothing. because you havn't told it do do anything yet. You need to put something in the main method - its what the program starts in

Ok I did put another bracket in, but then everything goes wrong. What do I need to do?

Oh wow, thanks.

But now when I try to run it, nothing comes up. Why wont it work?

Ok I did put another bracket in, but then everything goes wrong. What do I need to do?

Are you saying you put another bracket in after you put the bracket in?

ok like I put the end bracket to the main method at the end of the code, but when I did that all the variable names came up as errors and the computer says the void methods cant be used there. What do I need to do to make it work?

Or what part of my code needs to be in the main method brackets?

Or what part of my code needs to be in the main method brackets?

We have no idea what your program does, did you not write it without a point in which to start? If I wrote a console application without a main method, then wanted to "use" the class, I would do something along the lines of:

public class HelloWorld
{ 
	public void doSomething()
	{
		System.out.println("Hello World");
	}
		
	public static void main(String [] args)
	{
		//make an instance of helloworld to do something
                HelloWorld hw = new HelloWorld();
		hw.doSomething();
	}

}
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.