Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- using namespace std;
- void calculator() {
- //variables
- int num1;
- int num2;
- int num3;
- int num4;
- int result1;
- int result2;
- char operation = ' ';
- int max;
- while (true)
- {
- cout << "Choose a number - "; //asking first number
- cin >> num1;
- cout << "Choose a number two - "; //asking second number
- cin >> num2;
- result1 = num1 * num2;
- cout << "Continue? y/n \n"; // asking for next operation
- cin >> operation;
- if (operation == 'y')
- {
- cout << "Choose a number three - \n"; //asking third number
- cin >> num3;
- cout << "Choose a number four - \n"; //asking fourth number
- cin >> num4;
- result2 = num3 + num4;
- }
- else
- {
- cout << "The first sum is - " << result1; // first result
- break;
- }
- cout << "Do you want to continue with these two results? choose y/n\n";
- cin >> operation;
- if (operation == 'y')
- {
- cout << "Choose what I do with them + or - or / or * \n";
- char action = ' ';
- cin >> action;
- switch (action)
- {
- case '+':
- max = result1 + result2;
- cout << "The sum of the results - " << max << "\n";
- break;
- case '-':
- max = result1 - result2;
- cout << "The differrence of the results - " << max << "\n";
- break;
- case '*':
- max = result1 * result2;
- cout << "The product of the results - " << max << "\n";
- break;
- case '/':
- max = result1 / result2;
- cout << "The division of the results - " << max << "\n";
- break;
- default:
- break;
- }
- }
- else
- {
- cout << "Result one - " << result1 << "\n" << "Result two - " << result2 << "\n";
- break;
- }
- break;
- }
- }
- int main()
- {
- calculator();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement