Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <cmath>
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- cout << "Nate's \"Open Source\" BMI Calculator! \n\n";
- double myWeight;
- double myHeight;
- double row1;
- double row2;
- double row3;
- double row4;
- cout << "Enter your height 'SPACE' and then weight and then hit 'ENTER'. \n";
- cin >> myHeight >> myWeight;
- double weight2 = myWeight * 0.45;
- double height2 = myHeight * .025;
- double height3 = height2 * height2;
- double myBmi = weight2 / height3;
- cout << "Your BMI is " << myBmi << endl;
- ifstream bmiTable;
- string tableLine1;
- string tableLine2;
- string tableLine3;
- string tableLine4;
- bmiTable.open("bmi.txt");
- bmiTable >> tableLine1 >> tableLine2 >> tableLine3 >> tableLine4;
- cout << tableLine1 << " \n" << tableLine2 << " \n" << tableLine3 << " \n" << tableLine4 << " \n";
- //This is the block of code where I was going to do the extra credit and then got frustrated not knowing how to make a math equation in C++
- //where I compare bmi to be in between two possible values which I would assign to 18.5 and 24.9
- //
- if (myBmi < 18.5)
- cout << "You are UNDERWEIGHT." << endl;
- else if (18.5 <= myBmi <= 24.9)
- cout << "You are NORMAL." << endl;
- else if (24.9 <= myBmi <= 29.9)
- cout << "You are OVERWEIGHT." << endl;
- else if (myBmi > 30.0)
- cout << "You are OBESE." << endl;
- cin.ignore(256, '\n');
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement