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
|
#include <string>
#include <iomanip>
#include <fstream>
#include <iostream>
using namespace std;
void introduction();
void inputValue(double &feetValue, double &inchValue);
double calculation(double &coninch, double &confeet);
void finaloutput(double &meterft, double &meterin, double &totalmeter);
double meterft, meterin, totalmeter;
double feetValue, inchValue;
int main()
{
introduction();
inputValue(feetValue, inchValue);
calculation(meterft, meterin );
finaloutput(meterft, meterin, totalmeter);
}
void introduction()
{
cout << "This program will accept an input of feet and/or inches. From there the program will convert the value into meters." << endl;
}
void inputValue(double &feetvalue, double &inchValue )
{
cout << "Please enter the number of feet." << endl;
cin >> feetValue ;
cout << "Please enter the number of inches." << endl;
cin >> inchValue ;
cout << "You've entered: " << feetValue << " feet." << endl;
cout << "You've entered: " << inchValue << " inches." << endl;
}
double calculation(double &coninch, double &confeet)
{
double inch2feet = 12 ;
double feet2meter = .3048 ;
double meterft, meterin;
meterft = (feetValue * feet2meter) ;
meterin = (feet2meter *(inchValue / inch2feet));
double totalmeter = meterft + meterin ;
cout << meterft << " " << meterin << " " << totalmeter << endl;
return totalmeter;
}
void finaloutput(double &meterft, double &meterin, double &totalmeter)
{
cout << "So these are your final values for your inputs in meters." << endl;
cout << "For feet entered: " << meterft << endl;
cout << "For inches entered: " << meterin << endl;
cout << "Total of both: " << totalmeter << endl;
}
|