Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // The original version of this code was created by Kenneth Davis (@Coatless_Eskimo).
- // If you modify this code, include this message and release the source code for free.
- #include <iostream>
- int additionLoop()
- {
- int x{};
- int y{};
- std::cout << "Please define X. \n";
- std::cin >> x;
- std::cout << "Please define Y. \n";
- std::cin >> y;
- std::cout << "Your answer is: " << x + y << "." << std::endl;
- }
- int subtractionLoop()
- {
- int x{};
- int y{};
- std::cout << "Please define X. \n";
- std::cin >> x;
- std::cout << "Please define Y. \n";
- std::cin >> y;
- std::cout << "Your answer is: " << x - y << "." << std::endl;
- }
- int multiplicationLoop()
- {
- int x{};
- int y{};
- std::cout << "Please define X. \n";
- std::cin >> x;
- std::cout << "Please define Y. \n";
- std::cin >> y;
- std::cout << "Your answer is: " << x * y << "." << std::endl;
- }
- int divisionLoop()
- {
- int x{};
- int y{};
- std::cout << "Please define X. \n";
- std::cin>>x;
- std::cout << "Please define Y. \n";
- std::cin>>y;
- std::cout << "Your answer is: " << x / y << "." << std::endl;
- }
- int squaringLoop()
- {
- int x{};
- std::cout << "Please define X. \n";
- std::cin >> x;
- std::cout << "Your answer is: "<< x * x << "." << std::endl;
- }
- int helpMePlease()
- {
- std::cout << "This code made and compiled by Coatless Eskimo. \n";
- }
- int calculatorLoop()
- {
- std::cout << "Please choose an operation to be performed. \n" << " \n" << "1. Addition \n" << "2. Subtraction \n" << "3. Multiplication \n" << "4. Division \n" << "5. Square \n" << "6. Help" << std::endl;
- int choice{};
- std::cin >> choice;
- if (choice == 1)
- additionLoop();
- else if (choice == 2)
- subtractionLoop();
- else if (choice == 3)
- multiplicationLoop();
- else if (choice == 4)
- divisionLoop();
- else if (choice == 5)
- squaringLoop();
- else if (choice == 6)
- helpMePlease();
- else
- std::cout << "Please make a valid selection. \n";
- calculatorLoop();
- }
- int main()
- {
- calculatorLoop();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement