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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
#include <iostream>
using namespace std;
char a, b, c, d, e, f, g, h, howman = '\0';
int yesno, yesnoy;
float howmany;
int main ()
{
while (a != 'e')
{
a = b = c = d = e = f = g = h = 'n';
howmany = howman;
yesno = howman;
yesnoy = howman;
cout << "What would you like to convert?\nType 't' for temperature or 'e' to exit.\n";
char what;
cin >> what;
if (what == 'e') return 0;
else if (what != 't' && what != 'e')
{
cout << "Sorry, but we can not convert what you asked for. All we can convert is temperature.\n\n";
}
else if (what == 't')
{
while (b != 'e')
{
cout << "From what would you like to convert?\nType 'c' for degrees celcius, 'f' for degrees fahrenheit or 'e' to exit.\n";
char whata;
cin >> whata;
if (whata == 'c')
{
while (c != 'e')
{
cout << "To what would you like to convert?\nType 'f' for degrees fahrenheit, or type 'e' to exit.\n";
char whatc;
cin >> whatc;
if (whatc == 'f')
{
while (h != 'e')
{
g = 'n';
cout << "How many degrees celcius would you like to convert to degrees fahrenheit?\n";
cin >> howmany;
float result;
result = howmany * 1.8 + 32;
cout << howmany << " degrees celcius equals to " << result << " degrees fahrenheit.\n\nDo you want to convert something else?\nType 'y' for yes, 'n' for no or 'e' to exit.\n";
cin >> yesno;
if (yesno == 'n' || yesno == 'e') return 0;
else if (yesno == 'y')
{
while (g != 'e')
{
cout << "Is the conversion you want to make still from celcius to fahrenheit?\nType 'y' for yes, 'n' for no or 'e' to exit.\n";
cin >> yesnoy;
if (yesnoy == 'n')
{
b = c = g = h = 'n';
}
else if (yesnoy == 'y')
{
howmany = howman;
yesno = howman;
yesnoy = howman;
g = 'e';
}
else if (yesnoy == 'e')
{
return 0;
}
else
{
cout << "Sorry, but we didn't understand your answer to the question. You should have answered either 'y' for yes, 'n' for no or 'e' to exit.\n\n";
}
}
}
}
}
else if (whatc == 'e')
{
return 0;
}
else
{
cout << "Sorry, but we can not convert from degrees celcius to what you asked for. All we can convert to from degrees fahrenheit is degrees celcius.\n\n";
}
}
}
else if (whata == 'f')
{
while (d != 'e')
{
cout << "To what would you like to convert?\nType 'c' for degrees celcius, or type 'e' to exit.\n";
char whatb;
cin >> whatb;
if (whatb == 'c')
{
while (e != 'e')
{
f = 'n';
cout << "How many degrees fahrenheit would you like to convert to degrees celcius?\n";
cin >> howmany;
float result;
result = (howmany - 32) / 1.8;
cout << howmany << " degrees farenheit equals to " << result << " degrees celcius.\nDo you want to convert something else?\nType 'y' for yes, 'n' for no or 'e' to exit.\n";
cin >> yesno;
if (yesno == 'n' || yesno == 'e') return 0;
else if (yesno == 'y')
{
while (f != 'e')
{
cout << "Is the conversion you want to make still from fahrenheit to celcius?\nType 'y' for yes, 'n' for no or 'e' to exit.\n";
cin >> yesnoy;
if (yesnoy == 'n')
{
b = d = e = f = 'e';
}
else if (yesnoy == 'y')
{
g = 'e';
}
else if (yesnoy == 'e')
{
return 0;
}
else
{
cout << "Sorry, but we didn't understand your answer to the question. You should have answered either 'y' for yes, 'n' for no or 'e' to exit.\n\n";
}
}
}
}
}
else if (whatb == 'e')
{
return 0;
}
else
{
cout << "Sorry, but we can not convert from degrees fahrenheit to what you asked for. All we can convert to from degrees fahrenheit is degrees celcius.\n\n";
}
}
}
else if (whata == 'e') return 0;
else
{
cout << "Sorry, but we can not convert from what you asked for. All we can convert from is degrees celcius or fahrenheit.\n\n";
}
}
}
}
}
|