Hey everyone, i seem to be having a little bit of a problem with my coding for converting CM into inches, i get the answer no problem, but i then need to times the answer by itself to get the correct value but i'm unsure how to do so, here is my code.
Code:
/*
* File: main.cpp
* Author: 20524455
*
* Created on 01 December 2010, 08:59
*/
#include <cstdlib>
#include <iostream>
#include <math.h>
using namespace std;
char gender;
char height;
int while_cnt = 0;
char option1 ='y';
int femcnt;
int malecnt;
int J=2.54;
int underweight;
int normalweight;
int overweight;
int obese;
int underweightf;
int normalweightf;
int overweightf;
int obesef;
double Imperial;
double Metric;
char weight;
double Imperial2;
double Metric2;
double choice1;
double choice2;
double BMI1;
int I = 703;
int main() {
cout<<"Created and Designed by Rhys Thomas, 2010-2011"<<endl;
cout<<"Male/Female: Body Mass Index Calculator"<<endl;
cout<<"In both Metric and Imperial Calculations"<<endl<<endl<<endl;
while (option1 == 'y')
{
cout<<"Please specify your Gender: (M/F)"<<endl;
cin>>gender;
if ((gender =='M')||(gender =='m') )
{
cout<<" "<<endl<<endl;
cout<<"You have chosen Male"<<endl<<endl;
malecnt = malecnt +1;
}
else if ((gender =='F')||(gender =='f') )
{
cout<<" "<<endl<<endl;
cout<<"You have chosen Female"<<endl<<endl;
femcnt= femcnt +1;
}
cout<<"Would you like your Height in Inches or Meteres? (I/M)"<<endl;
cin>>height;
cout<<" "<<endl<<endl;
if ((height =='I')||(height =='i') )
{
cout<<"Please enter your Height in Inches: "<<endl;
cin>>Imperial;
Imperial= Imperial * Imperial;
choice1=Imperial;
cout<<" "<<endl<<endl;
}
else if ((height =='M')||(height =='m') )
{
cout<<"Please enter your Height in Cetremetres: "<<endl;
cin>>Metric;
cout<<" "<<endl<<endl;
Metric= Metric / 2.54; <<<<<<<<PROBLEM CODE
choice1=Metric;
cout<<choice1;
}
cout<<"Would you like your Weight in Pounds or KG? (P/K)"<<endl;
cin>>weight;
cout<<" "<<endl<<endl;
if ((weight =='P')||(weight =='p') )
{
cout<<"Please enter your Weight in Pounds: "<<endl;
cin>>Imperial2;
Imperial2= Imperial2 * I;
cout<<Imperial2;
choice2=Imperial2;
BMI1= choice2 / choice1;
cout<<BMI1;
cout<<" "<<endl<<endl;
cout<<"Your BMI is " <<BMI1<<endl<<endl;
}
else if ((weight =='K')||(weight =='k') )
{
cout<<"Please enter your Weight in KG: "<<endl;
cin>>Metric2;
choice2=Metric2 * 2.2 * I;
BMI1= choice2 /choice1;
cout<<BMI1;
cout<<" "<<endl<<endl;
cout<<"Your BMI is " <<BMI1<<endl<<endl;
}
if (BMI1 <=17.5)
{
cout<<"You are classed within the: Under-Weight Group"<<endl<<endl;
if ((gender =='M')||(gender =='m') )
{
cout<<" "<<endl<<endl;
underweight=underweight+1;
cout<<"The current Male count for this group is :" <<underweight<<endl<<endl;
}
else if ((gender =='F')||(gender =='f') )
{
underweightf=underweightf+1;
cout<<"The current Female count for this group is :" <<underweightf<<endl<<endl;
}
}
if (BMI1 >=18)
{
cout<<"You are classed within the: Normal Weight Group"<<endl<<endl;
if ((gender =='M')||(gender =='m') )
{
normalweight=normalweight+1;
cout<<"The current Male count for this group is :" <<normalweight<<endl<<endl;
}
else if ((gender =='F')||(gender =='f') )
{
normalweightf=normalweightf+1;
cout<<"The current Female count for this group is :" <<normalweightf<<endl<<endl;
}
}
if (BMI1 >=25)
{
cout<<"You are classed within the: Over-Weight Group"<<endl<<endl;
if ((gender =='M')||(gender =='m') )
{
overweight=overweight+1;
cout<<"The current Male count for this group is :" <<overweight<<endl<<endl;
}
else if ((gender =='F')||(gender =='f') )
{
overweightf=overweightf+1;
cout<<"The current Female count for this group is :" <<overweightf<<endl<<endl;
}
}
if (BMI1 >=30)
{
cout<<"You are within the: Obese Group"<<endl<<endl;
if ((gender =='M')||(gender =='m') )
{
obese=obese+1;
cout<<"The current Male count for this group is :" <<obese<<endl<<endl;
}
else if ((gender =='F')||(gender =='f') )
{
obesef=obesef+1;
cout<<"The current Female count for this group is :" <<obesef<<endl<<endl;
}
}
while_cnt++;
cout<<"do you wish to enter another BMI ? (y/n)"<<endl<<endl;
cin>>option1;
}
cout<<"The total of each group is as followes: "<<endl<<endl;
cout<<"Males Under-Weight: "<<underweight<<endl;
cout<<"Female's Under-Weight " <<underweightf<<endl;
cout<<"Males Normal-Weight: "<<normalweight<<endl;
cout<<"Female's Normal-Weight " <<normalweightf<<endl;
cout<<"Males Over-Weight: "<<overweight<<endl;
cout<<"Female's Over-Weight " <<overweightf<<endl;
cout<<"Males Obese: "<<obese<<endl;
cout<<"Female's Obese: " <<obesef<<endl;
cout<<"The total male count is: ";
cout<<malecnt<<endl;
cout<<"The total female count is: ";
cout<<femcnt<<endl;
return 0;
}