bmi calculator- convert (do while) to (array)

i need some help,right now i do bmi calculator in do while..i need some help,if someone know how to change it to array..this is my programm:

#include <iostream>
#include <cmath>

float bmi(float, float); //prototype
float bmi_inpound(float, float); //prototype

int main (int argc, char * const argv[]) {
float height_cm, weight_kg, height_inch, weight_pound, ur_bmi, ur_bmi_inpound;
char height_unit = 'a', weight_unit = 'a';
std::cout << "Welcome to the BMI Centre.\n";

do {
std::cout << "Please select the unit of your height:\n";
std::cout << "Press I for inch. Press C for centimeter.\n";
std::cin >> height_unit;

if (height_unit=='I') {
std::cout << "Please enter your height:\n";
std::cin >> height_inch;
}
else if(height_unit=='C') {
std::cout << "Please enter your height:\n";
std::cin >> height_cm;
}
} while (height_unit != 'I'||height_unit != 'C');

do {
std::cout << "Please select the unit of your weight:\n";
std::cout << "Press P for pound. Press K for kilogram.\n";
std::cin >> weight_unit;

if (weight_unit=='P') {
std::cout << "Please enter your weight:\n";
std::cin >> weight_pound;
}
else if(weight_unit=='C'); {
std::cout << "Please enter your weight:\n";
std::cin >> weight_kg;
}
} while (weight_unit!='P'||weight_unit!='K');

if (height_unit=='I') {
ur_bmi_inpound = bmi_inpound(weight_pound, height_inch);
std::cout << "Your BMI is " << ur_bmi_inpound << ".\n";
std::cout << "Thank you.\n";
}
else if(height_unit=='C') {
ur_bmi = bmi(weight_kg, height_cm);
std::cout << "Your BMI is " << ur_bmi << ".\n";
std::cout << "Thank you.\n";
}
return 0;
}

float bmi_inpound (float w, float h) {
float final_bmi;
final_bmi = w * 704.5 * h / h;
return final_bmi;
}

float bmi (float w, float h) {
float final_bmi;
final_bmi = w /pow(h,2.0);
return final_bmi;
}
@aizat
This is your program using functions. Not sure what you mean by
in array
Anyway, hope this is of use. I changed it to either - or for American and Metric. Otherwise, weight could be entered in pounds and height in centimeters.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// BMI - 2.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <cmath>

void Inches();
void Centimeters();
float bmi(float, float); //prototype
float bmi_inpound(float, float); //prototype

int main (int argc, char * const argv[])
{
	char unit = ' ';
	std::cout << "Welcome to the BMI Centre.\n";

	do
	{
		std::cout << "Please select the unit of Measurements : \n";
		std::cout << "Press A for American. Press M for Metric.\n";
		std::cin >> unit;
		unit = toupper( unit );
		std::cout << "UNIT = " << unit << "\n";
	} while (unit != 'A' && unit != 'M');

	if (unit=='A')
	{
		Inches();
	}
	else
		Centimeters();

	return 0;
}

void Inches()
{
	float height_inch, weight_pound, bmi_A;
	std::cout << "Please enter your height in inches :\n";
	std::cin >> height_inch;
	std::cout << "Please enter your weight in pounds :\n";
	std::cin >> weight_pound;
	bmi_A = bmi_inpound(weight_pound, height_inch);
	std::cout << "Your BMI is " << bmi_A << ".\n";
	std::cout << "Thank you.\n";
}

void Centimeters()
{
	float height_cm, weight_kg, bmi_M;
	std::cout << "Please enter your height in centimeters :\n";
	std::cin >> height_cm;
	std::cout << "Please enter your weight in kilograms :\n";
	std::cin >> weight_kg;
	bmi_M = bmi(weight_kg, height_cm);
	std::cout << "Your BMI is " << bmi_M << ".\n";
	std::cout << "Thank you.\n";
}

float bmi_inpound (float w, float h)
{
	double final_bmi;
	final_bmi = w * 704.5 * h / h;
	return final_bmi;
}

float bmi (float w, float h) 
{
	float final_bmi;
	h=h*h;
	final_bmi = w /h;;
	return final_bmi;
}
thank u my friend, this program using the process (do_while) right? right now i need to convert it to (two dimensional arrays) or (switch case)...thnk u for ur help..
Topic archived. No new replies allowed.