Create a new class called idealweight

Assignment Help JAVA Programming
Reference no: EM131154605

Introduction to Programming

Quiz: More Expressions

Activities

1. Create the uncp.csc1760.quizzes.quiz2 package.

2. In the new package, create a new class called IdealWeight. Make sure your new class is fully defined and has a main method. This  class will calculate the ideal weight (and the acceptable ranges) of both males and females. The testing of this functionality will also be included.

3. Inside the class but outside the main method, paste the following code:

public static void printIdealWeight(int feet, int inches)
{
//constants
//variables declarations and calculations
//output
}

This method will calculate and print out the ideal weight for males and females along with a range of acceptable weights.

Important Note: There are two parameters to the function printIdealWeight: feet and inches. They represent the person's height.

So, if this code was run for a person who is 5'7", then feet would have the value 5 and inches would have the value 7. These are variables that you will need in your calculations.

4. Add JavaDoc comments ("/**") for the main method, the printIdealWeight method and the class. Be sure to include:
• A brief description of the purpose (for all of them)
• @author tags (for the class)
• @version tag (for the class)
• @param tag (for both methods)

5. Use the following description for the rest of the instructions. According to one study, the ideal weight for a female is 100 pounds plus 5 pounds for each inch in height over 5 feet. For example, the ideal weight for a female who is 5'3" would be 100 + 5 * 3 = 115
pounds. For a male the ideal weight is 106 pounds plus 6 pounds for each inch in height over 5 feet. For example, the ideal weight for a male who is 6'2" would be 106 + 14*6 =190 pounds (because he is 14 inches above 5 feet).

Generally, however, a person's weight is okay if it is within about 15% of the ideal. That is, a person's weight is considered normal if it is between the ideal weight minus 15% to the ideal weight plus 15%.

6. In the main method, add 3 tests. You will be calling your code with something like :

printIdealWeight(5,0); //Height = 5 ft 0 in

Where the 5 is the number of feet and the 0 is the number of inches.

7. Add comments above the tests indicating the expected values (including the ranges) for both sexes. To do this, you will need to determine what formulas you need to develop to calculate the values. It is strongly suggested that you record your steps as comments for your reference.

a. Determine how to convert a height in feet and inches into a total number of inches. (You did this in a previous lab.)

b. Determine how to find the number of inches over 5 feet if you have a height in inches.

c. Determine the formula for the ideal weight of a female. Use the description above.

d. Determine the formula for the ideal weight of a male. Use the description above.

e. Determine how to calculate 15% of a value.

Once you have determined the formulas you need, calculate the answers you expect from your tests and add them above your tests as
comments.

Note: If you are unsure of your formulas, ask the instructor.

Note: Running the program at this point will not produce any output.

8. Create two int constant values. One should store the base weight for females (i.e. the ideal weight for a female that is 5'0") and the
other should store the pounds per inch for each inch above 5'0" for females (i.e. the increase in the ideal weight for each inch in
height). Name them appropriately and place them in the printIdealWeight method under the constants comment.

9. Declare three int variables and assign values to them. Pick good names for the variables that represent their purpose. Place the  code below the calculation comment in the printIdealWeight method.

a. Declare an int variable to store the total height in inches. Use the feet and inches variables and your formula from step 7 to
calculate its value.

b. Declare an int variable to store the number of inches above 5'0". Use the total height in inches and your formula from step 7 to calculate its value.

c.Declare an int variable to store ideal weight for a female. Use your constants, the number of inches above 5'0" and your formula from step 7 to calculate its value.

10. Using print or println statements, create an output message that displays the ideal weight. The message must indicate that the
ideal weight is for a female.

a.Also print the range of acceptable weights. You will need your formula for calculating 15% of a value and the ideal weight. These can be stored in variables (what type should they be?) or the calculations can be done directly in the output statements. If you use additional variables, be sure to declare them.

Sample output is provided below. Your output does not have to match the sample as long as it provides the required information.

11. Save and run the program. Check to see if you

12. Repeat steps 9-12 for the male ideal weight. You do not need to calculate the total height in inches or the number of inches above 5'0" again. You can just use those values in your other calculations. You will need separate variables for the ideal weight for a male and, if you are storing them, 15% below and 15% above the ideal weight for a male.

13. Run the program and check to see if your output matches your expectations.

14. Format the class and save it.

15. Submit all of your .java files to Blackboard.

Attachment:- Assignment.rar

Reference no: EM131154605

Questions Cloud

What is the original premise of sas culture : What is the original premise of SAS culture? What is the importance of the SAS culture on work/home balance
What expectations do your audience members have : What expectations do your audience members have in relation to your speech? What are possible beliefs audience members have about you according to your demographic qualities? What environmental factors might shape the way your audience members respon..
Essay - value of dissent in our society : Write an essay on one of the given topics, it must not exceed from words. Online Learning: A Boon(2500 Words with reference) and Value of dissent in our society (2500 Words with reference)
Create a java application that stores employee details : SD2720: Module Using Operators, Arrays, and Constructs Lab. Create a Java application that stores and maintains the employee details, including employee ID, employee name, department, designation, marital status, and date of marriage, in a multidim..
Create a new class called idealweight : CSC 1760 Introduction to Programming. In the new package, create a new class called IdealWeight. Make sure your new class is fully defined and has a main method. This class will calculate the ideal weight (and the acceptable ranges) of both males..
Write a computer program to automatically analyze data : For this assignment, you have been asked to write a computer program to automatically analyze some of the data collected by some experiments. Data analysis in scientific research is a complicated endeavor, so we will simplify our task by just calc..
Write a java program with the given functionalities : Write a Java program with the following functionalities: It should use a one-dimensional array. It should enable the user to search for an element in the array
Design and implement the class day : Design and implement the class Day that implements the day of the week in a program. The class Day should store the day, such as Sun for Sunday. The program should be able to perform the following operations on an object of type Day: Set the day
What is the optimum operating reaction temperature : For a reversible exothermic elementary catalytic reaction of the type A B, what is the optimum operating reaction temperature at a conversion level , xa = 0.8 given- K1 = exp ( 10 -5000/T) K2 = exp ( 40 - 15000 /T) and maximum allowable temperatu..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Design a program that extends the definition of the class

Design a program that extends the definition of the class JFrame to display a window on the screen. Name your class PropertyTax1, title your window "Calculation of Property Taxes," set the window's width to 400 pixels and height to 300 pixels, and te..

  Method splitstack that takes a stack

Write a method splitStack that takes a stack of integers as a parameter and splits it into negatives and non-negatives. The numbers in the stack should be rearranged so that all the negatives appear on the bottom of the stack and all the non-negat..

  Design a class named magazinesubscription

Design a class named MagazineSubscription that has fields for a subscriber's name, the magazine name, and number of months remaining in the subscription.

  Implement a method with signature transfer

Implement a method with signature transfer(S, T) that transfers all elements from stack S onto stack T, so that the element that starts at the top of S is the first to be inserted onto T, and the element at the bottom of S ends up at the top of T...

  Develop a form based front end for a class management

In this assignment, students will develop a form based front end for a class management system and a database using a combination of JDBC commands, SQL, and Swing GUI components to allow users to query, insert, update and delete records using a si..

  User-defined methods

You will create the ShoutBox class for your Virtual World. Your ShoutBox class will have a shoutOutCannedMessage() method that returns a String type.

  Design the appropriate accessor and mutator methods

Design an Employee class that has fields for the following pieces of information: Employee Name Employee Number Next, design a class named ProductionWorker that extends the Employee class.

  Online reservation and bookeeping software for beauty salon

Online Reservation and Bookeeping Software for Beauty Salon - develop a software (with Java) for a beauty salon, which will replace a current paper based system, so that people could make reservations online and administrator could do book keeping.

  What command is used to create a java archive

What command is used to create a Java archive? Describe using an example.

  Create a frame-based application that displays an array

Include a TextField in the South. When the user clicks a button, the course name should display in the TextField

  Which statement is true about a non-static inner class

Which statement is true about a non-static inner class? Clicking the closing button on the upper-right corner of a frame generates a(n) _____ event.

  What is the starting index of an array

What are your concerns? In Java, what is the starting index of an array

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd