Well I am now starting a new program and it evolves get the users height, weight, age and then calculating it into hat, waist, jacket sizes. I have to have four made methods in it also. One for each clothing size and on for asking the user if they want to cont or quit.

Here's what I have to do,

Write a Java program that will read information about a person and then will output clothing sizes for the person.

The begins by asking the user to enter the person's height (in inches), weight (in pounds), and age (in years) - and must do so in this order. After retrieving these values, the program should display the following menu and ask the user to make a choice:

  1. Calculate Hat Size
  2. Calculate Jacket Size
  3. Calculate Waist Size
  4. No More Calculations

The user should input a value of 1, 2, 3, or 4. If the user does not enter one of those four values, the program should output an error message and ask the user to choose again. This process should continue until the user selects one of the menu options.

Once the user has selected one of the menu options, the program should take the appropriate action:

Option 1: Calculate and display the person's hat size
Option 2: Calculate and display the person's jacket size
Option 3: Calculate and display the person's waist size
Option 4: Quit the menu loop for this person

When the user chooses option 4, the program should ask if there is another person for which to calculate sizes.

If the user answers yes, then the program should start over again, asking for the height, weight, and age.
If the user answers no, then the program should stop.

Calculations

Hat size (in inches) is calculated by dividing weight by height and then multiplying the result by 2.9

Jacket size (in inches) is calculated by multiplying weight and height and then dividing the result by 288

After doing the base calculation for jacket size, the resulting answer must be adjusted by adding 1/8 of an inch for each 10 years of age, starting at age 40.

Example: suppose that the weight times height produces an answer of 38.8 inches.
If the age is 35, then the final answer will be 38.8 inches.
If the age is 40, then the final answer will be 38.8 inches + (1/8 inch) = 38.925 inches
If the age is 50, then the final answer will be 38.8 inches + (2/8 inch) = 39.05 inches

Waist size (in inches) is calculating by dividing weight by 5.7

After doing the base calculation for waist size, the resulting answer must be adjusted by adding 1/10 of an inch for each 2 years of age, starting at age 30.

Example: suppose that the weight divided by 5.7 produces an answer of 36.842 inches.
If the age is 28 or 29, then the final answer will be of 36.842 inches.
If the age is 30 or 31, then the final answer will be of 36.842 inches + (1/10 inch) = of 36.942 inches
If the age is 32 or 33, then the final answer will be of 36.842 inches + (2/10 inch) = of 37.042 inches

This is my code so far,

import java.util.*;

public class Sizes {


    public static void main(String[] args, double answer1, int answer2, double answer3) {

        Scanner kbd = new Scanner(System.in);
        int height, weight, age, hat, waist, jacket, choice;

        do
        {

        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();

        public static void menu()
        {
        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();



        }
        }

        public static double hatSize (double answer1, double hatSize)
        {
            int choice;
            if (choice == 1)
            {
                int weight;
                int height;
                answer1 = weight/height * 2.9;
                System.out.println("Your hat size is" + answer1);
            }
        return hatSize;
        }

        public static double jacketSize (double answer2, double jacketSize)
        {
            int choice;
            if (choice == 2)
            {
                int weight;
                int height;
                answer2 = weight * height / 288;
                System.out.println("Your jacket size is" + answer2);
            }
            return jacketSize;
        }

        public static double waistSize (double answer3, double waistSize)
        {   
            int choice;
            if (choice == 3)
            {
                double weight;
                answer3 = weight / 5.7;
                System.out.println("Your waist size is" + answer3);
            }
            return waistSize;
        }

        public static double pick4 (int answer4, double pick4, double menu)
        {   
            int choice;
            if (choice == 4)
            {
                Scanner kbd = new Scanner(System.in);
                System.out.println("Is there another person for which to calculate sizes?" + " " + "(Y/N)");
                answer4 = kbd.nextInt();
                int Y, N;

                if (answer4 == Y)
                {
                    return menu;
                }
                else 
                    if (answer4 == N)
                    {   
                        System.out.print("Thanks");
                    }
            }
            return pick4;
        }


    }

I know that I need a while statement after the do statement. So My question is, what do I do next and what I am doing right and what I am doing wrong?

Thanks

Basing from your coding, I think that you assume that when you write the method, the program will execute it. Correct me if Im wrong okie??

You see, writing a method in your program doesnt necessarity mean that your program will execute it. You have to call that method inside your main method.

Suggestions:

  1. Basic method construction is this

    public returnType methodName(input parameters) {}

In your main method

public static void main(String[] args, double answer1, int answer2, double answer3) {

just leave the String[] args, omit the double,int,double because you will not be passing these variables to your main method.

  1. You need to do a do-while statement in the menu method, not in the input of height, weight, age.

  2. After the user have supplied the height, weight, age (which you got from the Scanner), you call the method menu.

Hint: menu should accept no input parameters but should return an integer. Inside this method you will do your do-while condition.

Try this first and post again if you have questions or got stucked (",)

Also next time you post, put your codes inside the CODE-tags.

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.