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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
# include <iostream>
using namespace std;
void input(double &feet, double &inches);
void conversion (double feet, double &inches, int &meters, double ¢imeters);//prototype
void output(int meters, double centimeters); //prototype
void main () //Input Function
{
int meters;
double feet, inches, centimeters;
char menu;
do
{
cout << " Do you want to convert another set of values?(Y/N): ";
cin >> menu;
input(feet, inches);
conversion(feet, inches, meters, centimeters);
output (meters, centimeters);
if (menu == 'N' || menu == 'n');
{ cout << "End of Program " << endl;
break;
}
}while (menu == 'Y' || menu == 'y');
}
void input(double &feet, double &inches)
{
cout << "Enter feet: ";
cin >> feet;
cout << "Enter inches: ";
cin >> inches;
}
void conversion (double feet, double &inches, int &meters, double ¢imeters)
{
inches += 12 * feet;
centimeters = inches * 2.54;
meters = centimeters/100;
centimeters -= meters*100;
}
void output (int meters, double centimeters)
{
cout << "Result of conversion: " << meters << " meter(s) and " << centimeters << " centimeters " << endl;
system ("Pause");
}
|