Created
October 19, 2016 22:21
-
-
Save anonymous/a6d18b11e249a4be9ea14fecbeaca50c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//calculator by jake molina | |
//includes iostream | |
#include <iostream> | |
//Standard namespace | |
using namespace std; | |
void main() | |
{ | |
//Declare the variables | |
float Number_1; | |
float Number_2; | |
float Result; | |
int Which_Calculation; | |
// Give Instructions. | |
cout << "Choose a task. Press 1 to add, 2 to subtract, 3 to multiply, 4 to divide then press enter" << endl; | |
cin >> Which_Calculation; | |
//Get numbers | |
cout << "Please enter the first number then press enter." << endl; | |
cin >> Number_1; | |
cout << "Please enter the second number then press enter ." << endl; | |
cin >> Number_2; | |
//Addition if command | |
if (Which_Calculation == 1) | |
{ | |
//Calculate the result | |
Result = Number_1 + Number_2; | |
} | |
//Subtract if command | |
if (Which_Calculation == 2) | |
{ | |
//Calculate the result | |
Result = Number_1 - Number_2; | |
} | |
//Multiply if command | |
if (Which_Calculation == 3) | |
{ | |
//Calculate the result | |
Result = Number_1 * Number_2; | |
} | |
//Devide if command | |
if (Which_Calculation == 4) | |
{ | |
//Calculate the result | |
Result = Number_1 / Number_2; | |
} | |
//Prints Answer | |
cout << "The answer is..." << endl; | |
//Print the result | |
cout << Result << endl; | |
system("PAUSE"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment