#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
using std::cout;
using std::cin;
using std::getline;
using std::string;
using std::endl;
//const void SetHeight (int, int);
struct Mass{
doubleconst Get_Ht(double );
doubleconst Get_Wt(double );
};
/*
Can anyone work this challenge out,
well as you probably have noticed the decimal point is not correct,
I can't tell you where, however you could use std::fixed and::precision
but I doubt it will help.
You can't change the layout but you may notice that the decimal point is wrong,
I tried .00022 in wieght and it corrected it,
but pounds was effected, and altering the weight via 2.54 fixes the BMI
but effects the height.
The challenge i guess is to have the decimal place positioned in
their respective positions,
how ever a decimal place doesn't bother me as I got rather close. */
int main()
{
double Height, Weight;
double GH, GW, GM;
Mass Bmi;
//SetHeight (inch, feet);
cout << "Please type Height in feet:_";
//cin >> Height;
Height = 6.8;
GH = Bmi.Get_Ht(Height);
cout << "Please type Weight in pounds:_";
//cin >> Weight;
Weight = 205;
GW = Bmi.Get_Wt(Weight);
GM = GW/(GH*GH);
cout << "Your body mass index is:_" <<GM;
};
doubleconst Mass::Get_Ht(double Height){
double inch = 12.0, feet = 1, tmp = 0.0254;
double t = (tmp*Height)*(inch/Height )*Height;
cout << "\b = " <<t<<" meteres tall \n";
cout<< " ~~"<<endl;
return t;
};
doubleconst Mass::Get_Wt(double Weight){
float lb = 2.22, feet = 1.0;
double t = (feet / lb) * Weight;
cout << "\b = " << t << " kilos \n";
cout << " ~~" << endl;
return t;
};
While the code works, it prints every BMI accurately however only if a person who was 6.8 and maybe 200 pounds entered in the numbers the height would result in a decimal place 2 spots right of the zero, and that would be wrong, (2.07, but still not a big deal) and fixing it only results in 2.7, where the pounds conversation is now with out no decimal place.
Temp is temporary until the number serves a purpose.
I have seen those formulas before online, I can't say they helped finding how a BMI works because of the notation it's written in,
But the numbers you provided do work rather well, just not sure why.
Your original code didn't convert pounds to kilograms correctly.
You fixed the errors before I posted, good work.
Honestly, I looked at your first code and my brain shutdown. It wasn't what I'd do and it looked slightly overly complicated so I couldn't even motivate myself to really look at it to see the issue.
All I know is the code above works, so does the bottom one. The problem only reveals its self when you apply 6.8 inches, and 205 pounds, type anything else and it works. 21.6 BMI, 207.ect, 93kg converted but fails to place a decimal between 2.07ect.
Both yield the same output, if you type in 5.8inches and 190 pounds both have the decimal positions, not really sure why.
Top code now converts pounds to kilos correctly (92kg)with extra decimal places, but still has the decimal place 207.2423 when complied, just curious why.