Question

c++ pls

10D yUur Tugt Sna you will have to re-take it at another time PROBLEM 1 Body Mass Index (BMI) is a measure of body fat that is useful in screening for health issues. To calculate a BMi, you need the height in inches and the weight in pounds. You square the height, then divide the weight in pounds by the squared-height. BMI is defined in terms of meters and kilograms, so to convert from pounds and inches to meters and kilograms, simply multiply by 703 BMI (weight_in_pounds/(height_in_inches height_in_inches)) 703 Write a function called calculateBMI that will take as parameters the height in inches and the weight in pounds and it will return the corresponding BMI Write a main program where you will create three arrays, one for names (strings), one for heights in inches, and one for weights in pounds. Store the following values in the arrays: Names: Ann, Jen, Tim, Tom, Mike, Ben, Mon, Bob, Brad. Weights: 120, 152, 133, 222, 175, 150, 181, 162, 188. Heights: 65, 70, 75, 69, 55, 57, 69, 82, 57 The values stored in these arrays correspond to names, height in inches and the weight in pounds of users. Your program should loop through the arrays to calculate the BMI for each user and display the name and result. For example, the first two lines of output of your program should be: Ann, your BMI is 19.96. Jen, your BMI is 21.80.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find below the C++ code for the above problem. I have also attached 2 photos. One for the code and other for code and the output. 1 #include-<bits/stdc++.h> 2 using-namespace 4 float calculateBMI (int-height_in_inches, int weight_in_pounds) std calculatinExecute Embed main.cpp STDIN LlI Result #include <bits/stdc++.h> using namespace std; t+ -o main .cpp Smain Ann,your BMI is 1

#include <bits/stdc++.h>
using namespace std;

float calculateBMI(int height_in_inches, int weight_in_pounds)
{
   //calculating BMI
   float BMI = (weight_in_pounds/float(height_in_inches*height_in_inches))*703;
   return BMI;
}

int main()
{
   string names[9] = {"Ann", "Jen", "Tim", "Tom", "Mike", "Ben", "Mon", "Bob", "Brad"};
   int weights[9] = {120, 152, 133, 222, 175, 150, 181, 162, 188};
   int heights[9] = {65, 70, 75, 69, 55, 57, 69, 82, 57};

  

   for(int i=0;i<9;i++)
   {
       //converting float BMI value to string
       string s1 = to_string(calculateBMI(heights[i],weights[i]));
       // taking substring with 2 decimal values
       s1 = s1.substr(0,5);
       //printing output  
       cout<<names[i]<<",your BMI is "<<s1<<"."<<endl;
   }         
}

Add a comment
Know the answer?
Add Answer to:
c++ pls 10D yUur Tugt Sna you will have to re-take it at another time PROBLEM...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • IT Java code In Lab 8, we are going to re-write Lab 3 and add code...

    IT Java code In Lab 8, we are going to re-write Lab 3 and add code to validate user input. The Body Mass Index (BMI) is a calculation used to categorize whether a person’s weight is at a healthy level for a given height. The formula is as follows:                 bmi = kilograms / (meters2)                 where kilograms = person’s weight in kilograms, meters = person’s height in meters BMI is then categorized as follows: Classification BMI Range Underweight Less...

  • Please solve the following, please type out the code, and do not hand write because its...

    Please solve the following, please type out the code, and do not hand write because its hard to read. I would greatly appreciate it. (JAVA) Problem 1 In a class called H1P1, write a method called bmiOne that takes as arguments a mass in kilograms (a double) and a height in meters (also a double), and returns the body mass index (or BMI) for the given data. If we have mass -m kg and height-h meters, then BMI = Write...

  • How do you calculate BMI for a L bka? In the problem we have a patient...

    How do you calculate BMI for a L bka? In the problem we have a patient with a Left Below knee amputation and are suppose to calculate BMI for the patient: age:38 height: 69 inches weight: 210 pounds. I calculated BMI and got 31.0081916 but I don't know how to factor in the L bka. Please help thank you

  • I have this C program that calculates an input and converts it to a BMI calculation....

    I have this C program that calculates an input and converts it to a BMI calculation. Any idea how this would look as an LC3 program? I'm taking an LC3 programming class next semester and want an idea of what this code would even translate to, just trying to get a head start. I'm more so curious on how to get user input in a LC3 program, then I can try myself and figure it out from there. int main()...

  • Using C++ cs 102 REVIEW LAB Selection a) Minimum/Maximum: Nrite a program that asks the user...

    Using C++ cs 102 REVIEW LAB Selection a) Minimum/Maximum: Nrite a program that asks the user to enter two numbers. The progzan should use the conditional operator to determine which number is the smaller and which is the larger. Display your output in the format below: The smaller number is: (smallerNumber) The larger number is: ClargerNumber] b) Areas of Rectangles: The area of a rectangle is calculated by maltiplying its length tines its width. Write a program that asks the...

  • Please write this code in C++ Object-Oriented Programming, specify which files are .h, and .cpp, and...

    Please write this code in C++ Object-Oriented Programming, specify which files are .h, and .cpp, and please add comments for the whole code. Include a class diagrams, and explain the approach you used for the project and how you implemented that, briefly in a few sentences. Please note the following: -Names chosen for classes, functions, and variables should effectively convey the purpose and meaning of the named entity. - Code duplication should be avoided by factoring out common code into...

  • + Run C Code IMPORTANT: • Run the following code cell to create the input file,...

    + Run C Code IMPORTANT: • Run the following code cell to create the input file, biostats.csv, which you will be using later. 74, In [ ]: N %%file biostats.csv Name, Sex, Age, Alex, M, 41, Bert, M, 42, Dave, M, 39, Elly, F, 30, Fran, F, 33, Jake, M, F, Luke, M, 34, F Myra, M, M, 38, Ruth, F, 28, 22 22 323 47 47, Height, Weight 170 200 167 70 115 143 139 280 98 75, 350...

  • Use only if else nested if else only otherwise your answer won't be entertained. Problem 1(b):...

    Use only if else nested if else only otherwise your answer won't be entertained. Problem 1(b): Write a program that gives remainder without using modulus operator and loops. The first number entered will be dividend and second number entered will be divisor. Sample input: 15 6 Sample output: Remainder is 3 In a right triangle, the square of the length of one side is equal to the sum of the squares of the length of the other two sides. Write...

  • 3,4, and 5 please! 15 points Answer the following questions. Please show your work to help...

    3,4, and 5 please! 15 points Answer the following questions. Please show your work to help justify your Show critical thinking skills Narrative. J.R is a 27-year-old male. He is 5 feet, 9 inches tall. He weights 187 pounds. He runs three days a week, a moderate pace, for 20 minutes. On the weekends, he enjoys doing yardwork, walking his dog, and hanging out with his friends. J.R. would like to improve his overall diet, and he has the following...

  • Project 3 Instructions 1. Due Date & Time: 09-26-2020 at 11:59 PM WHAT TO SUBMIT Submit...

    Project 3 Instructions 1. Due Date & Time: 09-26-2020 at 11:59 PM WHAT TO SUBMIT Submit 1 zip file containing 4 files below to iLearn by the deadline. [30 points] ● 3 JAVA Files: TableBmiPro.java, MyOwnIdea.java. DiceRoll.java [24 points] ● 1 File: Make a document that shows the screen captures of execution of your programs and learning points in Word or PDF. Please make sure you capture at least 2 executions for 1 program, so 6 screen captures and one...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT