Question
Create the entire Sizes program. Begin by copying your hatSize, jacketSize, waistSize and menu methods from the assignment and pasting them into the Sizes file,
Create the entire Sizes program.
Begin by copying your hatSize, jacketSize, waistSize and menu methods from the assignment and pasting them into the Sizes file, so you can use these methods to help you complete the project.
THESE ARE THE METHODS:
HATSIZE METHOD
--------------------------------------------------------------
public class Sizes {
public static void main(String[] args) {
System.out.println("Begin test");
hatSize(1, 1);
System.out.println("Test complete");
}
// Write the hatSize method here
public static double hatSize(int weight, int height){
double calcHatSize;
double widHgt=(double)weight/height;
calcHatSize=widHgt*2.9;
return calcHatSize;
}
}
------------------------------------------------------------------------
JACKET SIZE METHOD:
public class Sizes {
public static void main(String[] args) {
System.out.println("Begin test");
jacketSize(1, 1, 1);
System.out.println("Test complete");
}
// Write the jacketSize method here
public static double jacketSize(int weight, int height, int age){
double size = (weight * height)/288.0;
int extra = 0;
if(age >=40){
extra = 1;
extra +=((age - 40)/10);
}
size +=(extra/8.0);
return size;
}
}
-------------------------------------------------------------------------------
WAISTSIZE METHOD:
public class Sizes {
public static void main(String[] args) {
System.out.println("Begin test");
waistSize(1, 1);
System.out.println("Test complete");
}
// Write the waistSize method here
public static double waistSize(int weight, int age){
double size = weight/5.7;
int adjustment = 0;
if(age >=30){
adjustment = 1 + ((age -30)/2);
}
size+=(adjustment/10.0);
return size;
}
}
-----------------------------------------------------------------
MENU METHOD:
import java.util.*;
public class Sizes {
public static Scanner kbd;
public static void main(String[] args) {
kbd = new Scanner(System.in);
System.out.println("Begin test");
System.out.println("Method returned: " + menu());
System.out.println("Test complete");
kbd.close();
}
// Write the menu method here
public static int menu(){
int num;
while (true){
System.out.println("1. Calculate Hat Size");
System.out.println("2. Calculate Jacket Size");
System.out.println("3. Calculate Waist Size");
System.out.println("4. No More Calculations");
System.out.print(" Enter your choice: ");
num = kbd.nextInt();
if(num>=1&&num<=4){
return num;
}
System.out.println();
}
}
}
--------------------------------------------------------------------------------------
STARTER CODE YOU MUST USE:
import java.util.*;
public class Sizes {
public static Scanner kbd;
public static void main(String[] args) {
kbd = new Scanner(System.in);
kbd.close();
}
}
----------------------------------------------------------------------------------------
Your program should begin by asking the user to enter the height, weight and age. The user's inputted values are shown below in italics.
Enter your height (in inches): 65 Enter your weight (in pounds): 159 Enter your age (in years): 35
Next, display the menu on the screen by using your menu method. The user's inputted values are shown below in italics.
1. Calculate Hat Size 2. Calculate Jacket Size 3. Calculate Waist Size 4. No More Calculations Enter your choice: 2
If the user entered 1, 2 or 3, then you should display the requested size on the screen. The size should be formatted to display exactly three decimal places.
Your jacket size is: 35.885 inches
Continue displaying the menu and displaying the requested sizes, until the user enters option 4. Once option 4 has been entered, your program should ask if the user wishes to calculate sizes for a different person. Your program should respond correctly if the user enters a capital or lowercase 'Y'.
If the user enters 'Y', then the program should go back and ask the user enter the height, weight and age. If the user enters 'N', then the program should end.
The following is an example of what your ong> see on the screen see on the screen when your program runs. The exact output depends on what values that the user types in while the program runs. The user's inputted values are shown below in italics. Note that your program must display the exact formatting shown here - including the spaces and blank lines.
Enter your height (in inches): 65 Enter your weight (in pounds): 159 Enter your age (in years): 35 1. Calculate Hat Size 2. Calculate Jacket Size 3. Calculate Waist Size 4. No More Calculations Enter your choice: 2 Your jacket size is: 35.885 inches 1. Calculate Hat Size 2. Calculate Jacket Size 3. Calculate Waist Size 4. No More Calculations Enter your choice: 4 Calculate sizes for another person (Y/N)? n
Here is another example program run:
Enter your height (in inches): 39 Enter your weight (in pounds): 98 Enter your age (in years): 11 1. Calculate Hat Size 2. Calculate Jacket Size 3. Calculate Waist Size 4. No More Calculations Enter your choice: 1 Your hat size is: 7.287 inches 1. Calculate Hat Size 2. Calculate Jacket Size 3. Calculate Waist Size 4. No More Calculations Enter your choice: 4 Calculate sizes for another person (Y/N)? Y Enter your height (in inches): 55 Enter your weight (in pounds): 158 Enter your age (in years): 29 1. Calculate Hat Size 2. Calculate Jacket Size 3. Calculate Waist Size 4. No More Calculations Enter your choice: 1 Your hat size is: 8.331 inches 1. Calculate Hat Size 2. Calculate Jacket Size 3. Calculate Waist Size 4. No More Calculations Enter your choice: 3 Your waist size is: 27.719 inches 1. Calculate Hat Size 2. Calculate Jacket Size 3. Calculate Waist Size 4. No More Calculations Enter your choice: 4 Calculate sizes for another person (Y/N)? N
Technical Notes & Requirements:
DO NOT use any other variables that are declared outside of a method. All variables (except the keyboard variable) should be declared locally to the appropriate method and passed to other methods (as needed) as parameters.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started