Need to insert a loop to the main menu!

I need help inserting a loop that will take me back to the main menu within each option. I also need a quit option in the main menu.




//This program has several options, first option calculates
//Body Mass Index, second option calculates Basal Metabolic Rate
//and the third option calculates how many macronutrients you should
//intake on a daily basis.
#include <iostream>

using namespace std;

void option1();
void option2();
void option3();

int main()
{
int option;

//Main Menu
cout << "There are three different options to chose from:" << endl;
cout << "Option 1 calculates your Body Mass Index (BMI)." << endl;
cout << "Option 2 calculates your Basal Metabolic Rate (BMR)." << endl;
cout << "Option 3 calculates your Macronutrients." << endl;
cin >> option;

if(option == 1)
{
option1();
}
if(option == 2)
{
option2();
}
if(option == 3)
{
option3();
}

system ("pause");
return 0;
}

void option1()
{
int HEIGHT;
int WEIGHT;
double BMI;

cout << "Please enter your height in inches." << endl;
cin >> HEIGHT;

cout << "Please enter your weight." << endl;
cin >> WEIGHT;

BMI = (WEIGHT * 705) / (HEIGHT * HEIGHT);

cout << "Your Body Mass Index is " << BMI << "." << endl;

system("pause");
}

//This option calculates your Basal Metabolic Rate
//which tells you how many calories you burn in a day
//additional without exercise.

void male();
void female();

void option2()
{
int gender;

cout << "What is your gender? (1 for male or 2 for female)" << endl;
cin >> gender;

if (gender == 1)
{
male();
}
if (gender == 2)
{
female();
}
}
void male()
{
int height;
int weight;
int age;
double BMR;

cout << "Please enter your height in inches." << endl;
cin >> height;

cout << "Please enter your weight in pounds." << endl;
cin >> weight;

cout << "Please enter your age." << endl;
cin >> age;

cout << "Thank you, now calculating your BMR ..." << endl;

BMR = 66 + (6.3 * weight) + (12.9 * height) - (6.8 * age);

cout << "Your Basal Metabolic Rate is " << BMR << "." << endl;
cout << "This amount of calories is what you need to intake on" << endl;
cout << "a daily basis to maintain weight." << endl;
}

void female()
{
int height;
int weight;
int age;
double BMR;

cout << "Please enter your height in inches." << endl;
cin >> height;

cout << "Please enter your weight in pounds." << endl;
cin >> weight;

cout << "Please enter your age." << endl;
cin >> age;

cout << "Thank you, now calculating your BMR ..." << endl;

BMR = 655 + (4.3 * weight) + (4.7 * height) - (4.7 * age);

cout << "Your Basal Metabolic Rate is " << BMR << "." << endl;
cout << "This amount of calories is what you need to intake on" << endl;
cout << "a daily basis to maintain weight." << endl;

system("pause");
}

//This option calculates how many calories you need to intake
//depending on your level of activity using your BMR calculated
//in option 2.

void male_macros();
void female_macros();

void option3()
{
int gender;

cout << "Please input your gender: 1 for male or 2 for female" << endl;
cin >> gender;

if (gender == 1)
{
male_macros();
}
else
{
female_macros();
}
}
void male_macros()
{
int weight;
int height;
int age;
double macros;

cout << "Please enter your height in inches." << endl;
cin >> height;

cout << "Please enter weight in pounds." << endl;
cin >> weight;

cout << "Please enter your age." << endl;
cin >> age;

macros = (10 * weight) + (6.25 * height) - ((5 * age) + 5);

cout << "Your macronutrient intake should be " << macros << "." << endl;
}

void female_macros()
{
int weight;
int height;
int age;
double macros;

cout << "Please enter your height in inches." << endl;
cin >> height;

cout << "Please enter weight in pounds." << endl;
cin >> weight;

cout << "Please enter your age." << endl;
cin >> age;

macros = (10 * weight) + (6.25 * height) - ((5 * age) - 161);

cout << "Your macronutrient intake should be " << macros << "." << endl;

system ("pause");
}
Topic archived. No new replies allowed.