Skip to content

Instantly share code, notes, and snippets.

@vinicioslc
Last active September 1, 2017 14:37
Show Gist options
  • Save vinicioslc/3d83ef979359793e9755bcce44c355d3 to your computer and use it in GitHub Desktop.
Save vinicioslc/3d83ef979359793e9755bcce44c355d3 to your computer and use it in GitHub Desktop.
Exercicio criado para prática de C++ Aula de Algoritmos Estácio
/* Script created for calculate BMI of Height and weight "inputed"
* this inform the total BMI and describes if the BMI is high or low
* Author : https://github.com/vinicioslc
* Creation Date : 01 - 08 - 2017
*/
#include <iostream>
using namespace std;
//Default ide comments...
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
//return true if "currentvalue" is betwen two values informed else return false.
bool IsBetween (float currentvalue, float minval, float maxval){
//value is greater of equal "minval" ? and is equal or smaller than "maxval"
if ( currentvalue >= minval && currentvalue <= maxval){
return true;
}
else {
return false;
}
}
//this method return to the user, details about total BMI
void PrintStateOfBMI (float bmi){
cout << "\n[ ";
if (bmi < 17){
cout << "This is too skinny...";
}
else if (IsBetween(bmi, 17, 18.49))
{
cout << "This is a low lightweight";
}
else if (IsBetween(bmi, 18.8, 24.9))
{
cout << "this is a ideal weight";
}
// is equals
else if (bmi == 25) {
cout << "you have a overweight";
}
else if (bmi > 25){
cout << "this is very fat";
}
else {
cout << "i don't know the awnser";
}
cout << " ]" << endl;
return;
}
// return total value of BMI According to the input weight and height
float ReturnBMI (float bweight, float bheight) {
return bweight / (bheight * bheight);
}
// default main method
int main(int argc, char** argv) {
float height = 0;
float weight = 0;
cout << "Enter your height Cm Ex.: 1.80 \n";
cin >> height;
cout << "Enter your weight Kg Ex.: 70 \n";
cin >> weight;
//calculate total BMI
float totalBMI = ReturnBMI(weight,height);
//Shows the weight, height, and the total BMI for the user
cout << "Resulting BMI it equals : " <<
"\nHeight :" <<
height <<
"\nWeight :" <<
weight <<
"\n \nTotal BMI :" << totalBMI << endl;
//Show the total BMI details for the user
PrintStateOfBMI(totalBMI);
//finish application
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment