Frux Posted October 13, 2016 Share Posted October 13, 2016 #include <cstdlib> #include <iostream> #include <math.h> using namespace std; /* * */ int main() { char gender; double weight, height, BMI; int age; cout<<"Welcome to Bulastog's BMI or Body Mass Index calculator!\n"<<endl; do{ cout<<"Select your gender: \n"; cout<<"M - Male\n"; cout<<"F - Female\n"; cout<<"Q - Quit\n"; cin>>gender; switch(gender){ case'M': case'm': cout<<"Enter your age:\n"; cin>>age; cout<<"Enter your weight in pounds:\n"; cin>>weight; cout<<"Enter your height in inches:\n"; cin>>height; cout<<"\n"<<endl<<endl; if(cin.fail()) { cin.clear(); cin.ignore(); cout<<"Please follow instructions.\nEnter again:\n"; cout<<"Age:"; cin>>age; cout<<"Weight:"; cin>>weight; cout<<"Height:\n"; cin>>height; } BMI = weight*703 / (height*height); if (age<17){ if (BMI<15){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are underweight."<<endl<<endl; }else if (BMI>=15&&BMI<20){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are average."<<endl<<endl; }else if (BMI>=21&&BMI<26){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are overweight."<<endl<<endl; }else if (BMI>=26){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are obese."<<endl<<endl; } }else if (age>=17&&age<35){ if (BMI<18.5){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are underweight."<<endl<<endl; }else if (BMI>=18.5&&BMI<25){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are average."<<endl<<endl; }else if (BMI>=25&&BMI<30){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are overweight."<<endl<<endl; }else if (BMI>=30){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are obese."<<endl<<endl; } }else if (age>=35){ if (BMI<19.5){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are underweight."<<endl<<endl; }else if (BMI>=19.5&&BMI<27){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are average."<<endl<<endl; }else if (BMI>=27&&BMI<30){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are overweight."<<endl<<endl; }else if (BMI>=30){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are obese."<<endl<<endl; } } break; case'F': case'f': cout<<"Enter your age:\n"; cin>>age; cout<<"Enter your weight in pounds:\n"; cin>>weight; cout<<"Enter your height in inches:\n"; cin>>height; cout<<"\n"<<endl<<endl; if(cin.fail()) { cin.clear(); cin.ignore(); cout<<"Please follow instructions.\nEnter again:\n"; cout<<"Age:"; cin>>age; cout<<"Weight:"; cin>>weight; cout<<"Height:\n"; cin>>height; } BMI = weight*703 / (height*height); if (age<17){ if (BMI<14){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are underweight."<<endl<<endl; }else if (BMI>=14&&BMI<19){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are average."<<endl<<endl; }else if (BMI>=20&&BMI<25){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are overweight."<<endl<<endl; }else if (BMI>=25){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are obese."<<endl<<endl; } }else if (age>=17&&age<35){ if (BMI<17.5){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are underweight."<<endl<<endl; }else if (BMI>=17.5&&BMI<24){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are average."<<endl<<endl; }else if (BMI>=24&&BMI<29){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are overweight."<<endl<<endl; }else if (BMI>=29){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are obese."<<endl<<endl; } }else if (age>=35){ if (BMI<18.5){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are underweight."<<endl<<endl; }else if (BMI>=18.5&&BMI<26){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are average."<<endl<<endl; }else if (BMI>=26&&BMI<29){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are overweight."<<endl<<endl; }else if (BMI>29){ cout<<"Your BMI is "<<BMI<<".\n"; cout<<"You are obese."<<endl<<endl; } } break; default: if ((gender == 'q')||(gender == 'Q')){ cout<<"\n"<<endl; cout<<"Thank you for using Bulastog's BMI calculator. BYE!"<<endl; }else{ cout<<"\n"; cout<<"Please follow instructions.\n"<<endl; } break; } }while((gender != 'q')&&(gender != 'Q')); return 0; } I'll give 1m ingame cash for who can make a flow chart for this source code. Could pay more if clean and correctly arrange :Shy: PS. I'm aware of those flow chart generator on web. Please, don't even think about it. Lol Our present sufferings are not worth comparing to the glory that will be revealed in us. -Romans 8:18 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now