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
|
// Converting Ft and In: This program will convert user input from feet and inches to
// meters and centimeters.
#include "stdafx.h"
#include <iostream>
using namespace std;
void input( int& feet, int& inches);
void output(int meters, int cetimeters);
void convert(int feet, int inches, int& meters, int¢imeters);
const double meterperfoot = 0.3048;
const int centimeterspermeter = 100;
const int inchesperfoot = 12;
int main()
{
{int feet;
int inches;
int meters;
int centimeters;
char menu;
do
{
cout << "Continue? (Y/N)";
cin >> menu;
input( feet, inches);
convert(feet, inches, meters, centimeters);
output( meters, centimeters);
}
while (menu == 'Y' || menu == 'y');
input(feet,inches);
cout << "Type the feet for the length:";
cin >> feet;
cout << "Type the inches for the length:";
cin >> inches;
convert( feet,inches,meters,centimeters);
inches += 12 * feet;
centimeters = inches * 2.54;
meters = centimeters/100;
centimeters -= meters*100;
output(meters,centimeters);
cout << "The converted length is:" << meters << "meters and" << centimeters << "centimeters" << endl;
return 0;
}
|