Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- calc:
- int a;
- int b;
- int c;
- int d;
- int e;
- int f;
- int g;
- int h;
- int i;
- int j;
- int total;
- cout << "This is a calculator. Press 1. for plus, 2. for minus 3. for multiplication 4. for division." << endl;
- cin >> a;
- if (a == 1)
- {
- cout << "You chose plus. Tell me first number." << endl;
- cin >> b;
- cout << "Now tell me another number." << endl;
- cin >> c;
- total = b + c;
- cout << "Result: " << endl;
- cout << total << endl;
- cout << "-------------------------------------------------------------------------------------------" << endl;
- cout << "If you still want to count, press 1, if you want to exit, press 2." << endl;
- cin >> j;
- if (j == 1)
- {
- goto calc;
- }
- if (j == 2)
- {
- exit(0);
- }
- else
- {
- cout << "Press 1 or 2." << endl;
- }
- }
- if (a == 2)
- {
- cout << "You chose minus. Tell me first number." << endl;
- cin >> d;
- cout << "Now tell me another number." << endl;
- cin >> e;
- total = d - e;
- cout << "Result: " << endl;
- cout << total << endl;
- cout << "-------------------------------------------------------------------------------------------" << endl;
- cout << "If you still want to count, press 1, if you want to exit, press 2." << endl;
- cin >> j;
- if (j == 1)
- {
- goto calc;
- }
- if (j == 2)
- {
- exit(0);
- }
- else
- {
- cout << "Press 1 or 2." << endl;
- }
- }
- if (a == 3)
- {
- cout << "You chose multiplication. Tell me first number." << endl;
- cin >> f;
- cout << "Now tell me another number." << endl;
- cin >> g;
- total = f * g;
- cout << "Result: " << endl;
- cout << total << endl;
- cout << "-------------------------------------------------------------------------------------------" << endl;
- cout << "If you still want to count, press 1, if you want to exit, press 2." << endl;
- cin >> j;
- if (j == 1)
- {
- goto calc;
- }
- if (j == 2)
- {
- exit(0);
- }
- else
- {
- cout << "Press 1 or 2." << endl;
- }
- }
- if (a == 4)
- {
- cout << "You chose division. Tell me first number." << endl;
- cin >> h;
- cout << "Now tell me another number." << endl;
- cin >> i;
- total = h / i;
- cout << "Result: " << endl;
- cout << total << endl;
- cout << "-------------------------------------------------------------------------------------------" << endl;
- cout << "If you still want to count, press 1, if you want to exit, press 2." << endl;
- cin >> j;
- if (j == 1)
- {
- goto calc;
- }
- if (j == 2)
- {
- exit(0);
- }
- else
- {
- cout << "Press 1 or 2." << endl;
- }
- }
- else
- {
- cout << "Press one of the numbers to count." << endl;
- cout << "--------------------------------------------------------------------------------------------" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment