Solved-Lab Assignment #4- Solution

$30.00 $19.00

Lab Objectives Be able to create complete Java programs with Simple arithmetic operations Conditional statements (if, if-else statements) Be able to use proper test data sets to thoroughly test and debug a program Task: BMI (Body Mass Index) Calculation Write a Java program to do: Ask user if he/she wants to your metric system or…

You’ll get a: . zip file solution

 

 

Description

5/5 – (2 votes)

Lab Objectives

  • Be able to create complete Java programs with

    • Simple arithmetic operations

    • Conditional statements (if, if-else statements)

  • Be able to use proper test data sets to thoroughly test and debug a program

Task: BMI (Body Mass Index) Calculation

Write a Java program to do:

  1. Ask user if he/she wants to your metric system or English system.

  2. Ask user to enter weight and height in corresponding units.

  3. Calculate the user’s BMI, and round the result to nearest integer.

  4. Issue a message based on user’s BMI (see the scale table below.)

  5. (Optional) design a fancy user interface (i.e. use nice greeting words, etc.)

BMI = (weight in kilograms) / (height in meters)2 or BMI = ( Weight in Pounds / ( Height in inches)2 x 703 (note: the result BMI is an integer.)

BMI scale table (simplified version)

BMI

<=24

25-29

>30

Status

normal

overweight

obese

Testing requirements:

Document your test cases below to make sure all the possible scenarios are tested plus a few error/wrong cases.

Test

Scenario

Test data used

output

1

English system, normal BMI

2

English, overweight

3

English, obese

4

Metric, normal

5

Metric, overweight

6

Metric, obese

7

Error due to wrong date format such as enter “3a2” for weight

8

Error due to wrong data values such as enter 0.0 for height

Submission

Create a script file showing your source program plus all 8 test runs. Submit two files, your Java source code (say yangBMI.java) and the script file on blackboard under Lab4.