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
|
#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
//variables
string var, var1;
float cm, mile, kilometer, inch, meter, AU, fahrenheit, celsius, foot, quit, i;
//program
i = 1;
while (i <= 1000000000) {
cout << "Enter the starting unit. For a list of all units and commands, type list. To exit, type quit. Please note that this program will only loop one billion times." << endl <<endl;
cin >> var;
cout << endl;
if (var == "quit")
{
return 0;
}
//list of functions
if (var == "list")
{
cout << "For cm to inch type centimeter. For inch to cm type inch. For miles to km type mile. For km to miles type kilometer. For meters to AU or feet type meter. For AU to meters type AU. For feet to meters type feet. For fahrenheit to celsius type fahrenheit. For Celsius to Fahrenheit type celsius then rerun the program." << endl << endl << endl;
}
//inches to centimeters
if (var == "inch")
{
cout << "Please enter the number of inches" << endl;
cin >> inch;
cm = inch * 2.54;
cout << "Distance in centimeters:" << endl;
cout << cm << endl;
}
//centimeters to inches
if (var == "centimeter")
{
cout << "Please enter the number of centimeters" << endl;
cin >> cm;
inch = cm / 2.54;
cout << "Distance in inches:" << endl;
cout << inch << endl;
}
//miles to kilometers
if (var == "mile")
{
cout << "Please enter the number of miles" << endl;
cin >> mile;
kilometer = mile * 1.609344;
cout << "Distance in kilometers:" << endl;
cout << kilometer << endl;
}
//kilometers to miles
if (var == "kilometer")
{
cout << "Please enter the number of kilometers" << endl;
cin >> kilometer;
mile = kilometer / 1.609344;
cout << "Distance in miles:" << endl;
cout << mile << endl;
}
//meters to AU or feet
if (var == "meter")
{
cout << "Please select which unit you would like to convert meters to out of Astronomical units and feet" << endl;
cin >> var1;
//AU
if (var1 == "AU");
{
cout << "Please enter number of meters" << endl;
cin >> meter;
AU = meter / 149598000000;
cout << "Distance in AU:" << endl;
cout << AU << endl;
}
//feet
if (var1 == "feet")
{
cout << "Please enter number of meters" << endl;
cin >> meter;
foot = meter * 3.2808399;
cout << "Distance in feet:" << endl;
cout << foot << endl;
}
}
//AU to meters
if (var == "AU")
{
cout << "Please enter number of AU" << endl;
cin >> AU;
meter = AU * 149598000000;
cout << "Distance in meters:" << endl;
cout << meter << endl;
}
//feet to meters
if (var == "feet")
{
cout << "Please enter number of feet" << endl;
cin >> foot;
meter = foot / 3.2808399;
cout << "Distance in meters:" << endl;
cout << meter << endl;
}
//fahrenheit to celsius
if (var == "fahrenheit")
{
cout << "Please enter temperature in Fahrenheit." << endl;
cin >> fahrenheit;
celsius = (fahrenheit - 32) * (5 / 9);
cout << "Temperature in celsius:" << endl;
cout << celsius << endl;
}
//celsius to fahrenheit
if (var == "celsius")
{
cout << "Please enter temperature in Celsius." << endl;
cin >> celsius;
fahrenheit = (celsius * (9 / 5)) + 32;
cout << "Temperature in Fahrenheit:" << endl;
cout << fahrenheit << endl;
}
i++;
}
system("PAUSE");
}
|