Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

General Requirements This assignment is to be completed individually. Group submissions will not be considered. Analyze the problem, design a documented plan (i.e. flowchart or

General Requirements

This assignment is to be completed individually. Group submissions will not be considered.

Analyze the problem, design a documented plan (i.e. flowchart or pseudo-code), code and test a solution

following the step-by-step approach presented in this course.

Submit your solution and plan to the appropriate assignment folder on DC Connect by the due date

provided.

Your instructor will assign a grade and post feedback on your submission to DC Connect.

Program Requirements

For this assignment you will create a simple Python application that will calculate the body mass index (BMI) of a person as well as a related description of their body mass index. The program will also determine how much weight to lose to move one category toward being healthy.

This application should accept a numeric height in inches value in the range of 20 to 120 inclusive, and a numeric weight in pounds value with a minimum value of 10 pounds. When either of these values is entered in an invalid format or outside of the acceptable range, immediately display an appropriate input error message then end the application. Entering invalid data should not crash the application. Only after valid height and weight values are entered should processing continue on to determine the BMI of the person and the categorization. After a successful calculation, display the height, weight, BMI and category for the BMI. If the BMI is not considered healthy, the program will also calculate and display the weight required to move one category toward being healthy. Below is an example of what the program output should look like under two different conditions:

Valid entry:

Invalid entry:

Please enter the persons height in Please enter the persons weight in 

The BMI for a 67.5 tall person who which is categorized as overweight. A healthier BMI category is 25, which can be reached at 162.0 lbs.

Press Enter to end this application... 

Please enter the persons height in inches: 19 ENTRY ERROR The height must be a number in the range of 20" to 120" inclusive! Please try again.

Press Enter to end this application... 
inches: 67.5 pounds: 173 
weighs 173.0 lb. is 26.7, 

2022 Durham College

Page 1 of 2

Assignment 1: Body Mass Index with Categories Selection

Assignment for COSC 1100 Intro to Programming

Detailed Requirements

Prompt the user to enter the persons height in inches and weight in pounds and store each of these values in appropriate variables. Note that both inches and pounds may be entered as real numbers.

When the user input for height is numeric, use a compound condition test to check that the value entered is within the range of 20 to 120 inclusive.

When the user input for weight is numeric, check that the value entered is greater than 10 lbs.

When the user input entered is not numeric (i.e. cannot be parsed into an appropriate value), display a

message indicating that it should be. When the user input entered is numeric but outside of the allowable range, display an error message indicating the range that is acceptable. Do not allow any processing to continue if the user input is not valid.

With valid input, we may calculate the BMI. BMI is the ratio of a persons mass in kilograms over their height in meters squared. Since our program is using imperial units, we must use a conversion factor of 703, which should be treated as a constant. Calculate the BMI using the following formula:

= () = () 703 hh2() hh2()

After the BMI is calculated, determine the category the BMI value falls into using an if ... else if decision structure based on the following:

A BMI of less than 16 is considered severely underweight

A BMI of 16 up to less than 18.5 is considered underweight.

A BMI of 18.5 up to less than 25 is considered healthy.

A BMI of 25 up to less than 30 is considered overweight.

A BMI of 30 or over is considered obese.

If the BMI is above or below healthy, set a target BMI value that is one step closer to healthy. i.e. If the BMI is severely underweight, the target BMI is 16 (underweight). If the BMI is underweight, the target BMI is 18.5 (healthy).

Use the target BMI value to determine what weight the person would need to change by one category, as shown in the sample output above. This can be done by assuming the persons height does not change.

Display these results as formatted string messages including the original user input, the calculated BMI to one decimal place, the BMI category, and the target weight if the BMI was not calculated as healthy. The format should match the example provided as closely as possible.

Prompt the user to press Enter to end the application, then end the application when the user presses Enter.

Style Guide Notes

To be eligible for full marks on this or any assignment in this course your application must conform to the requirements as outlined above as well as our prescribed style guide, in this case making sure to observe the PEP8 naming conventions for Python as well as appropriate and complete program documentation.

Development Hints

You may be tempted to utilize parts of your existing work or demo code as a starting point for this project. Be careful because while some things may be relevant, it is a different problem and there will be big differences! It is strongly recommended that you code this assignment following the from plan to program process from the beginning.

Be advised that an ideal solution to this problem may involve the declaration/assignment of multiple constants; possibly 5 or more.

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

Data Management Databases And Organizations

Authors: Watson Watson

5th Edition

0471715360, 978-0471715368

More Books

Students also viewed these Databases questions

Question

4. What will the team agreement contain?

Answered: 1 week ago