| CODE |
| #include <iostream> #include <cmath> using namespace std; void input (int& feet, double& inch); /*prompts the user for a value for feet and a value for inches to go through calculations into meters and centimeters*/ int meters (int feet, double inch); /*Will calculate meters from the number of feet and inches, will chop off the centimeters*/ double centimeters (int feet, double inch); /*Will calculate centimeters from the number of feet and inches, will chop off the meters*/ void output (int feet, double inch, int meter, double centimeters); /*echoes the input and reads out the value of meters and centimeters*/ int main() { int feet, meter, metersout; double inch, centimeter, centimetersout; char again; cout << "This program will prompt you for an integer value of feet " << "and a double value for inches (preferably to the nearest " << "tenth) and will output the equivilent value in meters and " << "centimeters\n\n\n"; do { input(feet, inch); metersout = meters(feet, inch); centimetersout = centimeters(feet, inch); output(feet, inch, metersout, centimetersout); cout << "Enter \"Y\" if you would like to run the program again"; cin >> again; }while (again == 'y' || again == 'Y'); return 0; } /*prompts the user for a value for feet and a value for inches to go through calculations into meters and centimeters*/ void input (int& feet, double& inch) { using namespace std; cout << "Enter a value for feet please\n"; cin >> feet; cout << "Enter a value for inches please\n"; cin >> inch; } /*echoes the input and reads out the value of meters and centimeters*/ void output (int feet, double inch, int meters, double centimeters) { using namespace std; cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(1); cout << "If you have " << feet << " feet and " << inch << "inches, " << "Then you have " << meters << " and " << centimeters << " centimeters \n\n"; } /*Will calculate meters from the number of feet and inches, will chop off the centimeters*/ int meters (int feet, double inch) { int meter; feet = feet + (inch / 12); meter= feet / 0.3048; return meter; } /*Will calculate centimeters from the number of feet and inches, will chop off the meters*/ double centimeters (int feet, double inch, int meters) { double centimeter, meter; inch = (feet * 12 ) + inch; centimeter = inch * 2.54; //2.54 is the number of centimeters in an inch. centimeter = centimeter - (meter*100); return centimeter; } |
| CODE |
| #include <iostream> #include <cmath> using namespace std; void input2 (int& meter, double& centimeter); /*prompts the user for a value for meters and a value for centimeters to go through calculations into meters and centimeters*/ int foot (int meter, double centimeter); /*Will calculate feet from the number of meters and centimeters, will chop off the centimeters*/ double inches (int meter, double centimeter); /*Will calculate inces from the number of meters and centimeters, will chop off the meters*/ void output2 (int feet, double inch, int meter, double centimeter); /*echoes the input and reads out the value of feet and inches*/ int main() { int feet, meter, feetout; double inch, centimeter, inchout; char again; cout << "This program will prompt you for an integer value of meters " << "and a double value for centimeters (preferably to the nearest " << "tenth) and will output the equivilent value in feet and " << "inches\n\n\n"; do { input2(meter, centimeter); feetout = foot(meter, centimeter); inchout = inches(meter, centimeter); output2(meter, centimeter, feetout, inchout); cout << "Enter \"Y\" if you would like to run the program again"; cin >> again; }while (again == 'y' || again == 'Y'); return 0; } /*prompts the user for a value for meters and a value for centimeters to go through calculations into feet and inches*/ void input2 (int& meter, double& centimeter) { using namespace std; cout << "Enter a value for meters please\n"; cin >> meter; cout << "Enter a value for centimeters please\n"; cin >> centimeter; } /*echoes the input and reads out the value of feet and inches*/ void output2 (int foot, double inches, int meter, double centimeter) { using namespace std; cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(1); cout << "If you have " << meter << " meters and " << centimeter << "inches, Then you have " << foot << " feet and " << inches << " inches \n\n"; } /*Will calculate feet from the number of meters and centimeters, w ill chop off the inches portion*/ int foot (int meter, double centimeter) { double foot; meter = meter + (centimeter / 100); foot= meter * 0.3048; return meter; } /*Will calculate inches from the number of meters and centimeters, will chop off the feet portion*/ double inches (int meter, double centimeter, int foot) { double inches; centimeter = (meter * 100) + centimeter; inches = centimeter / 2.54; //2.54 is the number of centimeters in an inch. inches = inches - (foot*12); return inches; } |
| CODE |
double centimeters (int feet, double inches); ... double centimeters (int feet, double inch, double meter ) { double centimeter, double meter; inch = (feet * 12 ) + inch; centimeter = inch * 2.54; centimeter = centimeter - (meter*100); return centimeter; } |
| CODE |
double inches (int meter, double centimeter); ... double inches (int meter, double centimeter, int foot) { double inches; centimeter = (meter * 100) + centimeter; inches = centimeter / 2.54; //2.54 is the number of centimeters in an inch. inches = inches - (foot*12); return inches; } |
| CODE |
void input (int& feet, double& inch) { using namespace std; cout << "Enter a value for feet please\n"; cin >> feet; cout << "Enter a value for inches please\n"; cin >> inch; } |
| CODE |
void input (int& feet, double& inch); ... input( feet,inch) |
| CODE |
void input( int &, double& ); ... input( feet, inch ) |
| CODE |
| void input (int& feet, double& inch); ... input( feet,inch) |
| CODE |
void input( int &, double& ); ... input( feet, inch ) |
| CODE |
| #include <iostream> using namespace std; void input (int& in_feet, double& in_inch); /*prompts the user for a value for feet and a value for inches to go through calculations into meters and centimeters*/ int meters (int feet1, double inch1); /*Will calculate meters from the number of feet and inches, will chop off the centimeters*/ double centimeters (int feet2, double inch2); /*Will calculate centimeters from the number of feet and inches, will chop off the meters*/ void output (int out_feet, double out_inch, int out_meter, double out_centimeters); /*echoes the input and reads out the value of meters and centimeters*/ int main() { int feet, meter, metersout; double inch, centimeter, centimetersout; char again; cout << "This program will prompt you for an integer value of feet " << "and a double value for inches (preferably to the nearest " << "tenth) and will output the equivilent value in meters and " << "centimeters\n\n\n"; do { input(feet, inch); metersout = meters(feet, inch); centimetersout = centimeters(feet, inch); output(feet, inch, metersout, centimetersout); cout << "Enter \"Y\" if you would like to run the program again"; cin >> again; }while (again == 'y' || again == 'Y'); return 0; } /*prompts the user for a value for feet and a value for inches to go through calculations into meters and centimeters*/ void input (int& feet, double& inch) { using namespace std; cout << "Enter a value for feet please\n"; cin >> feet; cout << "Enter a value for inches please\n"; cin >> inch; } /*echoes the input and reads out the value of meters and centimeters*/ void output (int feet, double inch, int meters, double centimeters) { using namespace std; cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(1); cout << "If you have " << feet << " feet and " << inch << "inches, " << "Then you have " << meters << " and " << centimeters << " centimeters \n\n"; } /*Will calculate meters from the number of feet and inches, will chop off the centimeters*/ int meters (int feet1, double inch1) { int meter; feet1 = feet1 + (inch1 / 12); meter= feet1 * 0.3048; return meter; } /*Will calculate centimeters from the number of feet and inches, will chop off the meters*/ double centimeters (int feet2, double inch2) { int mtemp; double cmtemp; inch2 = (feet2 * 12 ) + inch2; cmtemp = inch2 * 2.54; //2.54 is the number of centimeters in an inch. feet2 = feet2 + (inch2 / 12); mtemp= feet2 * 0.3048; //meters in a foot cmtemp = cmtemp - (mtemp * 100); return mtemp; } |
| CODE |
void test( int ); ... int main() { ... int y; test( y ); ... return 0; } ... void test( int yAlias ) { yAlias + 2; } |