Skip to content

Instantly share code, notes, and snippets.

@abonander
Forked from anonymous/Attempt
Created October 19, 2016 22:43
Show Gist options
  • Save abonander/f24724c97edc42947d2cc11bad79320f to your computer and use it in GitHub Desktop.
Save abonander/f24724c97edc42947d2cc11bad79320f to your computer and use it in GitHub Desktop.
//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