Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstdlib>
- using namespace std;
- double addition(double num1, double num2)
- {
- return num1 + num2;
- }
- double subtraction(double num1, double num2)
- {
- return num1 - num2;
- }
- double multiplication(double num1, double num2)
- {
- return num1 * num2;
- }
- double division(double num1, double num2)
- {
- return num1 / num2;
- }
- int main()
- {
- cout << "Welcome to the Ultimate Calculator of Lord Nur.\n";
- double number1;
- double number2;
- int choice;
- cout << "What do you want to do?\n 1 = Adding.\n 2 = Subtracting.\n 3 = Multiplying.\n 4 = Dividing.\n" << endl;
- cout << "Choice: ";
- cin >> choice;
- if (choice==1)
- {
- // Addition
- cout << "You are adding, enter the first number you would like to add. \nNumber 1:";
- cin >> number1;
- cout << "Enter the second number. \nNumber 2: ";
- cin >> number2;
- cout << "The result is: " << addition(number1, number2) << endl;
- }
- else
- {
- if (choice == 2)
- {
- // Subtraction
- cout << "You are subtracting, enter the first number you would like to subtract. \nNumber 1:";
- cin >> number1;
- cout << "Enter the second number. \nNumber 2: ";
- cin >> number2;
- cout << "The result is: " << subtraction(number1, number2) << endl;
- }
- else
- {
- if (choice==3)
- {
- // Multiplication
- cout << "You are multiplying, enter the first number you would like to multiply. \nNumber 1:";
- cin >> number1;
- cout << "Enter the second number. \nNumber 2: ";
- cin >> number2;
- cout << "The result is: " << multiplication(number1, number2) << endl;
- }
- else
- {
- {
- // Division
- cout << "You are dividing, enter the first number you would like to divide. \nNumber 1:";
- cin >> number1;
- cout << "Enter the second number. \nNumber 2:";
- cin >> number2;
- cout << "The result is: " << division(number1, number2) << endl;
- }
- }
- }
- }
- int choice2;
- cout << "Do you want to keep calculating or quit?\n1 = Keep calculating.\n2 = Quit.\n" << endl;
- cout << "Choice: ";
- cin >> choice2;
- if (choice2 == 1)
- {
- cout << "What do you want to do?\n 1 = Adding.\n 2 = Subtracting.\n 3 = Multiplying.\n 4 = Dividing.\n";
- cin >> choice;
- }
- else
- {
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement