Undefined
By: rechnerjow | Date: Nov 4 2009 10:31 | Format: C++ | Expires: never | Size: 902 B | Hits: 921
- #include <iostream.h>
- int main()
- {
- double x, y, z;
- char zeichen;
- bool b;
- cout << " TASCHENRECHNER" << endl <<endl;
- cout << "1. Operand: " ;
- cin >> x;
- cout << "Operation: " ;
- cin >> zeichen;
- cout << "2. Operand: ";
- cin >> y;
- b = true;
- switch (zeichen)
- {
- case '+': z = x + y; break;
- // break-Anweisung bewirkt Sprung zur 1. Anweisung
- // nach der switch-Anweisung
- case '-': z = x - y; break;
- case '*': z = x * y; break;
- case ':': case '/': z = x / y; break;
- default : cout << "Operation nicht durchfuehrbar"<< endl; b = false;
- }
- if (b) cout << "Ergebnis: " << z << endl;
- return 0;
- }
- /* Testlaeufe:
- TASCHENRECHNER
- 1. Operand: 17
- Operation: *
- 2. Operand: 33
- Ergebnis: 561
- TASCHENRECHNER
- 1. Operand: 1
- Operation: #
- 2. Operand: 1
- Operation nicht durchfuehrbar
- */
Latest pastes
1 days ago
1 days ago
11 months ago
13 months ago
17 months ago