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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
#include <iostream>
#include <cmath>
using namespace std;
void intro();
void introduction();
void get_value(int& value1);
void get_numbers(int& input1, int& input2);
double do_math(int meter);
double conversion(int feet, int inches);
void print_results(int output1, int output2);
void show_results(int results1, int results2);
int main(){
int m;
double final_pounds, final_inches, pounds_convert;
const int inch = 12;
int choice = 2;
char action;
cout<<"Welcome! Enter 1 to proceed to a metric system to English system conversion or enter 2 to proceed to an English system to metric system conversion."<<endl;
cin>>choice;
do {
if (choice == 1){
intro();
get_value(m);
pounds_convert = do_math(m);
final_pounds =(pounds_convert);
final_inches =(pounds_convert - (floor(final_pounds)))*inch;
print_results(final_pounds, final_inches);
}
else (choice == 2);
{
int f, i;
double final_meter, final_cm, end_meter;
const int meter = 100;
introduction();
get_numbers(f,i);
end_meter = conversion(f,i);
final_meter =(end_meter);
final_cm =(end_meter - (floor(final_meter)))*meter;
show_results(final_meter, final_cm);
}
} while (choice <= 2);
do{
cout<<"Do you want to repeat this English to metric calculation again? [y/n]"<<endl;
cin>>action;
} while (action == 'y');
return (0);
}
void intro()
{
using namespace std;
cout<<"Welcome! This program converts the metric sytems units to English system units."<<endl;
}
void get_value(int& value1 )
{
using namespace std;
cout<<"Enter the number of meter in integers: "<<endl;
cin>>value1;
}
double do_math(int meter)
{
using namespace std;
double pounds_convert;
double const foot = 0.3048;
pounds_convert = meter/foot;
return pounds_convert;
}
void print_results(int output1, int output2)
{
using namespace std;
cout<<"The value in metric systems are "<<output1<< " lb and "<<output2<< " inch "<<endl;
return;
}
void introduction()
{
using namespace std;
cout<<"Welcome! This program converts the English sytems units to metric system units."<<endl;
}
void get_numbers(int& input1, int& input2)
{
using namespace std;
cout<<"Enter the number of feet and inches integers separately: "<<endl;
cin>>input1;
cin>>input2;
}
double conversion(int feet, int inches)
{
using namespace std;
double total_meter, end_meter;
double const foot = 0.3048, inch = 12;
total_meter = feet+(inches/inch);
end_meter = total_meter*foot;
return end_meter;
}
void show_results(int results1, int results2)
{
using namespace std;
cout<<"The value in metric systems are "<<results1<< " m and "<<results2<< "cm"<<endl;
return;
}
|