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
|
//UNIVERT
#include <iostream>
using namespace std;
// Convert from "fromUnit" to "toUnit". using toVal = fromVal * conversionFactor
void convert(const char *fromUnit, const char *toUnit, double conversionFactor)
{
// WRITE THE CODE HERE
}
int
main()
{
//VARIABLES
int conversion;
cout << "*******************Welcome to UNIVERT*******************" << endl;
cout << " " << endl;
cout << "***************UNIVERSAL UNIT CONVERTER*******************" << endl;
cout << " " << endl;
cout <<
"**THE HARDER YOU WORK FOR SOMETHING, THE GREATER YOU'LL FEEL WHEN YOU ACHIEVE IT**"
<< endl;
cout << " " << endl;
//OPERATIONS
cout << "LIST OF FUNCTIONS:" << endl
<< " " << endl
<< " ***MASS CONVERSION*** " << endl
<< " " << endl
<< "1. kilogram to pounds" << endl
<< "2. pounds to kilogram" << endl
<< "3. grams to kilograms " << endl
<< "4. kilograms to grams" << endl
<< "5. grams to milligrams" << endl
<< "6. milligrams to grams " << endl
<< "7. grams to ounces " << endl
<< "8. ounces to grams " << endl
<< "9. kilogram to Ounce" << endl
<< "10. Ounce to kilogram " << endl
<< "11. kilogram to tons " << endl
<< "12. tons to kilogram " << endl;
cout << " " << endl << " " << endl;
//SELECTION OF OPERATION TO BE USED
cout << "Enter the NUMBER of the chosen Operation to be used: " << endl
<< " " << endl;
cin >> conversion;
//kilogram to pounds
if (conversion == 1) {
convert("kilograms", "pounds", 1/2.2046);
}
//pounds to kilogram
else if (conversion == 2) {
convert ("pounds", "kilograms", 2.2046);
}
//grams TO kilograms
else if (conversion == 3) {
convert("grams", "kilograms", 0.001);
}
//kilograms to grams
else if (conversion == 4) {
convert("kilograms", "grams", 1000);
}
// grams to milligrams
else if (conversion == 5) {
convert("grams", "milligrams", 1000);
}
// milli to grams
else if (conversion == 6) {
convert("milligrams", "grams", 0.001);
}
// grams to ounces
else if (conversion == 7) {
convert("grams","ounces",1/28.34952);
}
// ounces to grams
else if (conversion == 8) {
convert("ounces", "grams", 28.34952);
}
//kilogram to OZ
else if (conversion == 9) {
convert("kilograms","ounces",1/0.02834952);
}
// ounces to kilograms
else if (conversion == 10) {
convert("ounces","kilograms",0.02834952);
}
// kilogram to tons
else if (conversion == 11) {
convert("kilograms","tons",0.001);
}
// tons to kilograms
else if (conversion == 12) {
convert("tons","kilograms", 1000);
}
//DEFAULT
else {
cout << "Invalid input of Operations";
}
return 0;
}
|