CS1026a: Assignment 0

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment

Description

5/5 - (4 votes)

Background BMI
The Body Mass Index is the result of a formula that measures a persons weight against
their height. It is used as a rough guide to indicate whether a person is of healthy weight for their
height, or not. It has many shortcomings as a good measure for health, but is still widely used.
BMI = mass (ie. weight) in kilograms / (height in meters)2
Task:
In this assignment, you will write a complete program in Java that uses the SimpleInput
and SimpleOutput methods to create a simple Body Mass Index Calculator.
Functional Specifications:
1. Your program should ask the user for input using the available SimpleInput methods.
Specifically these three things: Their name, their weight in pounds and their height in
inches.
2. Your program should convert their weight into kilograms and their height into meters.
3. Your program should calculate the BMI using the formula given above.
4. You should display output to the user using the SimpleOutput.showInformation method:
a. A hello message,
b. their weight in kilograms (as a decimal number),
c. their height in meters(as a decimal number),
d. their BMI (as an integer),
e. and show them the normal range for a BMI.
These items should be displayed on separate lines. For example:
Non-functional Specifications:
• Include a comment at the top of your file which includes:
// CS1026B Assignment 0
// Your name
// A brief description of what this program does
• Also include brief comments in your code that explain the major steps of the program.
• Use named constants as appropriate.
• Use Java conventions and good Java programming techniques, for example:
o Meaningful variable names
o Conventions for naming variables and constants
o Readability: indentation, white space, consistency
• Assignments are to be done individually and must be your own work. Software may be
used to detect cheating.
What You Will Be Marked On:
• Functional specifications:
o Is the program written according to specifications?
o Does the program work as specified? Pay attention to details!
o Does it use the correct input and output methods
• Non-functional specifications: as described above
• Assignment submission: via OWL
Suggestions for Writing your Assignment
Often when faced with a problem, programmers are tempted to solve it all at once. This
can be too much to get a handle on for beginners or if the problem is large. A good strategy is to
pick at the problem in steps that you can test. This way, if you don’t get the whole assignment
finished, you would still have a working program and be eligible for part marks.
For example, consider how Lab 2 moves from Exercise 3 to 5. First, you have temperature
value (29.7) directly in the code (in computing we call this “hardcoded”). In this step, you figure
out how to perform the conversion and output the result simply to the interactions pane with
System.out.println. Then, once this is working, you can add the input of the temperature from the
User (ie. Exercise 5).
For this assignment, if a person’s weight were 150lbs and their height were 68 inches
(5’8’’), their BMI would be 22.80742… or as an integer 22.
Suggested Coding Process:
1. Get the conversions and BMI calculation working using hardcoded values (written
directly in the code) like this:
int wieghtInPounds = 150;
int heightInInches = 68;
2. Format the output to use the SimpleOuput method correctly (using the calculated
results from Step 1, as it will be much faster to test)
3. Get the user input working correctly