BMI Calculator

Scenario

A program has been written to calculate BMI values.

Each function that has been designed works as expected, except for the getWeight and getHeight functions which should only return data in a certain range.

Furthermore, the computer program calling the functins does not work at all!

Task 1

Start a new project and import or copy/paste code from the following Main class into your project area.

Troubleshoot the program and see if you can get it working as expected.

Also, fix the getHeight and getWeight functions so that they only return data in the expected range.

Task 2 - Persistent Storage

The doctor would like the data to be stored in a text file in secondary storage, eg SSD, in the following format:

Height:1.65; Weight:60; BMI: 22.1

Create a new function called writeToFile which takes the height, weight and BMI data as parameters. It creates a new file (if necessary) and appends the data in the above format to the file.

Use Java's FileWriter class to make this happen:

Note: on many computers, the complexity of your secondary storage is hidden from you. For example, on Windows machines it is simply shown to you as a drive letter, eg the C drive.

This is an example of abstraction: details which you do not need to know or understand are hidden from you.

Testing

Make sure you are thoughtful when testing your solution.

If your code has a validation check, test your code with acceptable/valid data and unacceptable/invalid data.