Write your question here.
Problem: Write a C++ program that read 5 people's height and weight data from the given file myinput.txt and then calculate EACH person's body mass index (BMI) using the formula below. After the calculation, your program should output each person's BMI to a file called myoutput.txt.
Note: In each line of the myinput.txt, the first data is the height in inches, the second data is the weight in lbs. Formula for body mass index: weight / (height )2 x 703
#include <fstream>
#include <iostream>
#include <cmath>
shadowCODE meant that on the right of the posting box, there are some buttons. One is for code. You basically copy your code then paste between the two headers.
With that said, you are missing a ';' after inFile >> ... weight5.
Without the use of arrays or classes, your work looks OK until after you read in the heights and weights.
BMI = weight / (height)pow(2) * 703;
This part should be calculated for each height and weight match, as long as that is the correct formula. To this end you should probably consider using a loop (if you have learned about those yet) to do the reading and conversions and output.
Please explain your 2 cout statements regarding conversion. Who is converting height to inches or weight into lbs? Or is that part of what you are supposed to do? Because the way the problem is described, it looks like the numbers go straight from the file to a calculation back to a separate file.
Not sure professionally when a file is supposed to be closed, but personally I close files just after I am completely through with them, i.e. I would close inFile just after the line inFile >> ... statement.
I end up fixing the program but I keep receiving an error known as Error 1 error C4700: uninitialized local variable 'base' used c:\temp\visual studio 2012\hw3_caver\hw3_caver\hw3_caver.source.cpp 22 1 HW3_Caver