Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Pay close attention to the directions!! Make absolutely certain that you are doing exactly what the assignment askes you to do. If you don't understand

Pay close attention to the directions!! Make absolutely certain that you are doing exactly what the assignment askes you to do. If you don't understand the problem, make sure to ask your instructor or an assistant.

This week, the assignment and the project both work together to create one single program. For the assignment, you will be writing and testing methods that you will use to create the project. Please read the overall description of the program before beginning the assignment or project.

description

You will be writing a Java application program that will read information about a person, and then will output clothing sizes for the person.

Your program will begin by asking the user to enter the person's height, weight and age. After retrieving this information , the program will display a menu and ask the user to make a choice from the menu:

Calculate Hat Size

Calculate Jacket Size

Calculate Waist Size

No More Calculations

The user is expected to enter a value of 1, 2, 3 or 4. If the user does not enter one of these 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 perform the requested calculation and display the result on the screen. When the user chooses option 4, the program has finished with this particular user.

Next 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 - asking for the next person's height, weight and age. If the user answers no, then the program should stop.

assignment part 1

There is already an existing class called Sizes, with an existing main method.

Inside the Sizes class, create a method called hatSize. The purpose of this method is to calculate a person's hat size.

Do not change any of the existing code in the main method, and do not add code to the main method. Changing the main method in any way will give you an automatic grade of zero on this part of the assignment.

This method should receive two integer parameters (in this order): weight and height. The method should calculate and return the hat size as a double value.

The hat size is calculated by dividing weight by height, and then multiplying by 2.9.

This method should NOT perform any screen output or keyboard input.

Testing:

The name of each test will tell you what parameter values are being passed to your method.

If your method is not written correctly (i.e. does not have the correct parameters or return value data types), then the tests will fail and will show nothing.

If your code does not compile, then the tests will fail and will show nothing.

If your method is written correctly, but returns the wrong value, then the test will show failed, and will tell you what value the method should be returning.

If your method is written correctly and returns the correct value, then the test will pass

assignment part 2

There is already an existing class called Sizes, with an existing main method.

Inside the Sizes class, create a method called jacketSize. The purpose of this method is to calculate a person's jacket size.

Do not change any of the existing code in the main method, and do not add code to the main method. Changing the main method in any way will give you an automatic grade of zero on this part of the assignment.

This method should receive three integer parameters (in this order): weight, height and age. The method should calculate and return the jacket size as a double value.

The jacket size 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.

As an 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

This method should NOT perform any screen output or keyboard input.

Testing:

The name of each test will tell you what parameter values are being passed to your method.

If your method is not written correctly (i.e. does not have the correct parameters or return value data types), then the tests will fail and will show nothing.

If your code does not compile, then the tests will fail and will show nothing.

If your method is written correctly, but returns the wrong value, then the test will show failed, and will tell you what value the method should be returning.

If your method is written correctly and returns the correct value, then the test will pass

assignment part 3

There is already an existing class called Sizes, with an existing main method.

Inside the Sizes class, create a method called waistSize. The purpose of this method is to calculate a person's waist size.

Do not change any of the existing code in the main method, and do not add code to the main method. Changing the main method in any way will give you an automatic grade of zero on this part of the assignment.

This method should receive two integer parameters (in this order): weight and age. The method should calculate and return the waist size as a double value.

The waist size is calculated by 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.

As an 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 method should NOT perform any screen output or keyboard input.

Testing:

The name of each test will tell you what parameter values are being passed to your method.

If your method is not written correctly (i.e. does not have the correct parameters or return value data types), then the tests will fail and will show nothing.

If your code does not compile, then the tests will fail and will show nothing.

If your method is written correctly, but returns the wrong value, then the test will show failed, and will tell you what value the method should be returning.

If your method is written correctly and returns the correct value, then the test will pass

assignment part 4

There is already an existing class called Sizes, with an existing main method.

Inside the Sizes class, create a method called menu. The purpose of this method is to display the menu on the screen and allow the user to make a choice from the menu.

Do not change any of the existing code in the main method, and do not add code to the main method. Changing the main method in any way will give you an automatic grade of zero on this part of the assignment.

This method does not need to accept any parameters from the main method. Choices should be read into the menu method from the keyboard as a number 1, 2, 3 or 4. This method will need to contain a loop which will repeat the process of displaying the menu and getting an input value as long as the user does not enter a correct menu option. After a correct menu option has been entered, the method should return that choice back to the main method.

Note that this method is required to verify that the entered choice is correct, so the main method does not have to do that task.

The following is an example of what your MIGHT see on the screen when your menu method executes. 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 method must display the exact formatting shown here - including the spaces and blank lines.

1. Calculate Hat Size 2. Calculate Jacket Size 3. Calculate Waist Size 4. No More Calculations Enter your choice: 1

Here is another example:

1. Calculate Hat Size 2. Calculate Jacket Size 3. Calculate Waist Size 4. No More Calculations Enter your choice: 5 1. Calculate Hat Size 2. Calculate Jacket Size 3. Calculate Waist Size 4. No More Calculations Enter your choice: 3

project part 1

getting started

Click the Open IDE button.

In the IDE window, look in the leftmost column and find the CSCI_1010 folder and inside it, find theproject09 folder.

Open the Java file - Sizes.java

the project

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.

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.

compiling the program

In the Terminal window, verify that the command prompt path shows: ~/csci_1010/project09 If it does not, ask your lab instructor for help.

Type javac Sizes.java to compile the java program.

testing the program

In the Terminal window, verify that the command prompt path shows: ~/csci_1010/project08 If it does not, ask your lab instructor for help.

Type javac Sizes.java to compile the java program.

Type java Sizes to execute the program.

submitting the project

In the leftmost column, right-click on the Sizes.java filename, and choose Submit file to Mimir.>In the New Mimir Submission window, choose Project09.

Click Submit. You should briefly see a message in the top right corner that says the Submission was Successful.

Go back to the Mimir Classroom and you should see where your file has been submitted, and automated tests have been performed on your file.

If it shows that all tests have been passed, then your file should be good.

If you find that any of the tests have failed, you can click on the "gear" icon beside the test to see the details of why the test failed. Ask your lab instructor for help if you do not understand what the results mean.

You can go back to the IDE and correct your file, test it yourself again, and then submit it again for regrading. You may submit your file up to 5 times.

grading

This project will This project will be graded on:

70% for correctness

30% for style and following directions:

Program is efficient and well structured

Program must contain comments to describe what the code is doing

EVERY METHOD must have comments before the method which describe:

the purpose of the method

the purpose of each parameter the method needs (if any)

the purpose of the return value (if not void)

Use good variable names (Do not variable names which consist only of a single letter)

Variable names must start with a lowercase letter

Variable data types are correct

Use good indention (Anything inside curly brackets should be indented)

Please refer to the programming standards guide posted on the course website.

I have already completed the assignments but I still need help with the project. Here are the assignments:

Assignment 1:

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(double weight, double height) { double value = (weight/height)*2.9; return value; } }

assignment 2:

public class Sizes {

public static void main(String[] args) { System.out.println("Begin test"); jacketSize(1, 1, 1); System.out.println("Test complete"); } 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; } }

assignment 3:

public class Sizes {

public static void main(String[] args) { System.out.println("Begin test"); waistSize(1, 1); System.out.println("Test complete"); } public static double waistSize(double weight , double age) { double waist= weight/5.7; for (double count = 29; count

assignment 4:

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

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 3 Lnai 9286

Authors: Albert Bifet ,Michael May ,Bianca Zadrozny ,Ricard Gavalda ,Dino Pedreschi ,Francesco Bonchi ,Jaime Cardoso ,Myra Spiliopoulou

1st Edition

3319234609, 978-3319234601

More Books

Students also viewed these Databases questions

Question

Know how productivity improvements impact quality and value.

Answered: 1 week ago

Question

Recommend the key methods to improve service productivity.

Answered: 1 week ago