Program 3: Create a program solution for the Body Mass Index Program Enhancement requirements (Programming exercise 10) on page 177 in the text book. Program Assumptions: 1. Use only the programming...







Program 3:





Create a program solution for the
Body Mass Index Program Enhancement
requirements (Programming exercise 10) on page 177 in the text book.






Program Assumptions:


1. Use only the programming capabilities taught in chapters 1 - 4. (This helps with standardized grading for all.)


2. Your program will run
once.


3. Your program will be the result of original work; not something found on the Internet, or given to you by someone else.



Primary Grading criteria:



1.

100% of your grade will come from your design documentation and program source code. (The Seven Step Problem Solving Methodology must be used.)



a.

Major Task List 5%



b.

Structure Chart 5%



c.

Word Analysis 5%



d.

Variable Chart 10%



e.

Pseudo code 20%



f.

Test Data 5%



g.

Desk Check 20%



h.

Actual C++ source code 20%



i.

Flowgorithm 10%


2. Your program
will require end user input
(weight and height).



3.
You must break down your solution into modular units. Main should contain only variables and calls to these modules:
getWeight, getHeight, setMass, setOverUnder, and showBMI.


4. Pass all variable arguments by
value.


5. You need to create three sets of test data that stress test the three possible fitness conditions.
Use 68” for the height in all three cases.


6. Your program must build and run as required without errors.


7. Pseudo Code and Source Code readability (by a fifth grader) is also a must:


a. Choose descriptive, not cryptic, variable names.


b. Comment to clarify what is going on as appropriate.



i. Section (block) comments guide.



ii. Line comments enlighten.


c. Use indentation to show structure clearly.


d. Use blank lines and spaces to increase readability.


e. At the top of your pseudo code and source code include these comments:



i. Program name



ii. Your names



iii. Program purpose



iv. Date created



v. Any programming assumptions you made in regards to the problem statement, for example: Assumed program will run once.



Submission Requirements:





1. Print and submit in class your hard-copy of the Eight Step Problem Solving Methodology Word document. Program3 must be submitted on time…no exceptions or excuses accepted.


2. At the end of your Eight Step Problem Solving Methodology Word document, copy and paste your C++ source code, and after that, a screen capture of your program’s output (see the sample you are supposed to bring to class each week for how to do this).


3. Required: Use Flowgorithm software to produce pseudo code to test your logic. Flowgorithm can also create your C++ source code.


4. Name your Flowgorithm file:
LastnameFirstInitial_Prog3.fprg;
for example,
BarberM_Prog2.fprg.

Upload it via the Assignment module for Program 3 in Canvas


5. Name your C++ source file:
LastnameFirstInitial_Prog3.cpp; for example,
BarberM_Prog2.cpp.

Upload it via the Assignment module for Program3 in Canvas
(that way I can run it inside the Integrated Development Environment if needed).


6. Make sure your Desk Check is on your
pseudo code, not your source code; and make sure you trace the value of ALL your variables and screen output. Otherwise, you have an invalid desk check with a major point loss.





Note:
Our
Blackboard Team Assist Forum
exists for students to ask questions when stuck. Everyone is encouraged to assist whenever possible. However, there is a fine line between assisting another student, and giving them the answer. If seeking assistance, you must be very specific when describing your problem…otherwise you probably will not get any answers. In addition, when answering, you may have to describe in general, or point to an appropriate reference, to avoid giving away code solutions. Use your best judgment. I will contact you via the Messaging system in Blackboard if you have stepped over the line.







Program 3 Eight Step Problem Solving Methodology



0. Problem Statement for Body Mass Index Program Enhancement:


Design a program that calculates a person’s body mass index (BMI). The BMI is often used to determine whether a person with a sedentary lifestyle is overweight or underweight for his or her height. A person’s BMI is calculated with the following formula:



BMI = (weight times 703) divided by height squared


In the formula, weight is measured in pounds and height is measured in inches. Enhance the program so it displays a message indicating whether the person has optimal weight, is underweight, or is overweight. A sedentary person’s weight is considered to be optimal if his or her BMI is between 18.5 and 25.0. If the BMI is less than 18.5, the person is considered to be underweight. If the BMI value is greater than 25.0, the person is considered to be overweight.


Avoid using magic numbers, create constants to represent the BMI factor of 703, BMI upper and lower limits.



1.

Major Task List
(Keep it abstract; focus on the “what” high level)


a. Determine health status using BMI


b. Display results





2.

Structure Chart
(Your blue print plan for your functions…who calls who)


























































































main


































































































































getWeight







getHeight







setMass







setOverUnder







showBMI














3.

Word Analysis:
(Which nouns suggest a need for memory (a variable) and which verbs suggest a need for action (a function maybe).


Design a program that calculates a person’s body mass index (BMI). The BMI is often used to determine whether a person with a sedentary lifestyle is overweight or underweight for his or her height. A person’s BMI is calculated with the following formula:



BMI = (weight times 703) divided by height squared


In the formula, weight is measured in pounds and height is measured in inches. Enhance the program so it displays a message indicating whether the person has optimal weight, is underweight, or is overweight. A sedentary person’s weight is considered to be optimal if his or her BMI is between 18.5 and 25.0. If the BMI is less than 18.5, the person is considered to be underweight. If the BMI value is greater than 25.0, the person is considered to be overweight.


Avoid using magic numbers, create constants to represent the BMI factor of 703, BMI upper and lower limits.






Nouns:

Verbs:



Program
design



BMI calculates



Person
is used



Lifestyle
determines



Overweight is calculated



Underweight
times



Optimal weight
divided



Height
squared



Weight measured



Formula
displays



Pounds
has



Inches
is



Message
is considered



Value
is between



BMI_Factor is less than



Is greater than



create







4.

Variable Chart:
(Conversion of verbs into camelCase variable names…may not all be here).



















































































































































Input



Interim



Output




Function












main


















BMI












healthStatus












weight












height






getWeight





















totalWeight















getHeight





















totalHeight















setMass















localVarWeight






totalMass






localVarHeight





















setOverUnder















localVarMass


















wellBeing



showBMI















localVarMass






localVarMass






localVarHealth






localVarHealth






Global Constants:



Constant real BMI_FACTOR = 703



Constant real MASS_LOWER_LIMIT = 18.5



Constant real MASS_UPPER_LIMIT = 25.0







5.

Pseudo Code
(use your Flowgorithm flow chart solution to produce pseudo code and C++ source code. Replace the given code here with yours.)


Note: Flowgorithm does not handle your global constants. Make them variables in the function that uses them.


//Declare global constants


Declare constant real BMI_FACTOR = 703


Declare constant real MASS_LOWER_LIMIT = 18.5


Declare constant real MASS_UPPER_LIMIT = 25.0




//Define Function Prototypes


Function real getWeight()


Function real getHeight()


Function real setMass(real, real)


Function string setOverUnder(real)


Function void showBMI(string, real)




Begin function main





// Declare variables



Declare real weight



Declare real height



Declare real BMI //Body Mass Index



Declare string healthStatus //Optimal, Under, or Over weight





// Get the user’s weight



Set weight = Call getWeight()





// Get the user’s height



Set height = Call getHeight()





// Calculate the user’s Body Mass Index



Set BMI = Call setMass(weight, height)





//Determine the user’s health status based on BMI



Set healthStatus = Call setOverUnder(BMI)





//Display the user’s BMI and health status



Call showBMI(healthStatus, BMI)





return 0




End function main




// Function Definition for getWeight


Function real getWeight ()





//Local variable declaration



Declare real totalWeight //To hold the user’s weight input from keyboard





//Prompt the user for weight



Display "Enter weight in pounds"



Get totalWeight //Takes the next real number from the input stream





return totalWeight //Sends value back to the caller




End function getWeight






// Function Definition for getHeight


Function real getHeight ()





//Local variable declaration



Declare real totalHeight //To hold the user’s height input from keyboard





//Prompt the user for height



Display "Enter height in inches"



Get totalheight //Takes the next real number from the input stream





return totalHeight //Sends value back to the caller




End function getHeight






//Function definition for setMass


Function real setMass (real localVarWeight, real localVarHeight)





//Local variable declaration



Declare real totalMass //To hold BMI





// Calculate user’s body mass index



Set totalMass = (______________________ * BMI_FACTOR) / (___________________ * localVarHeight)





return totalMass //Sends value back to the caller




End function setMass




//Functionn definition for setOverUnder, which determines user’s healthStatus base on BMI


Function string setOverUnder (real localVarMass)





//Declare local variable



Declare string wellBeing //To hold the user’s health status





// Determine user’s health status based on his/her BMI



if ____________ is less than ____________________ then



______________ = "underweight"



else if ______________________ is greater than _____________________ then



_______________= "overweight"



else



wellBeing = "optimal weight"





return wellBeing //Sends string value back to the caller




End function setOverUnder






//Function Definition for showBMI which displays the results


Function void showBMI (string localVarHealth, real localVarMass)


{





// Display user’s BMI



Display "Your BMI is ", __________________





// Display user’s health status



Display "You are ",_______________________




End function showBMI





6.

Test Data:


You will need three sets of test data (so you can do three desk check cases) for height and weight to cover the three possibilities in this problem.
























Variable



Case 1 Optimal Weight



Case 2 Under Weight



Case 3 Over Weight



totalWeight












totalHeight





















7.

Desk Check:
(make sure ALL your functions, variables, and output (display) are recorded here)


Note: All required variables may not be here.

























































































































































































































































































































































































































































Variable Name




Values




Values




Values







Screen Output






















Function











































main







Case 1




Case 2




Case 3






Case 1



























weight










































height










































BMI










































healthStatus


















































































getWeight













































totalWeight

























































Case 2



































































getHeight













































totalHeight


















































































setMass













































localVarWeight










































localVarHeight










































totalMass















Case 3



































































setOverUnder













































localVarMass










































wellBeing


















































































showBMI













































localVarHealth










































localVarMass














































8.

Source Code & Screen Capture







[Your source code goes here, with your screen capture of program output after it]




Oct 21, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here