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:
|
#include <iostream>
#include <stdlib.h>
/* Programm zur Umrechnung von Unze in Gramm und umgekehrt
am anfang auswahl, welcher mode, programmrepeatfunktion
1 unze (oz) = 28,34952 gramm
1 gramm = 0,035273965 unzen */
const double oz = 0.035273965;
char t = 'w', x;
double wert;
int main(int argc, char *argv[])
{
anfang:
// Programmbeschreibung
cout << "Programm zur Umrechnung Unze - Gramm" << endl;
cout << "u um von Unze in Gramm zu rechnen" << endl;
cout << "g um von Gramm in Unze zu rechnen" << endl;
cin >> x;
// Programmwiederholungsschleife
while (t='w') {
// Brechnung Unze - Gramm
if (x == 'u') {
cout << "\nBitte Wert in Unzen zur Berechnung eingeben: ";
cin >> wert;
cout << "Dieser Wert beträgt in Gramm: " << (wert/oz) << endl;
cout << "Bzw. in Kilogramm: " << ((wert/oz)/1000) << endl << endl;
}
else if (x == 'g') {
cout << "\nBitte Wert in Gramm zur Berechnung eingeben: ";
cin >> wert;
cout << "Dieser Wert beträgt in Unzen: " << (wert*oz) << endl << endl;
}
else {
cout << "\nUngueltige Eingabe" << endl << endl;
goto anfang;
}
cout << "w zum wiederholen, b zum beenden ";
do
cin.get(t);
while (t != 'b' && t != 'w');
}
cin.sync ();
cin.clear ();
return 0;
} |