From 7a73162607544204032aa66cce755daf21edebda Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Tue, 24 May 2022 11:18:46 -0500 Subject: Graduate Signed-off-by: Matt Strapp --- ee1301/wk2/lab2/calc.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 ee1301/wk2/lab2/calc.cpp (limited to 'ee1301/wk2/lab2/calc.cpp') diff --git a/ee1301/wk2/lab2/calc.cpp b/ee1301/wk2/lab2/calc.cpp new file mode 100644 index 0000000..9cb2e03 --- /dev/null +++ b/ee1301/wk2/lab2/calc.cpp @@ -0,0 +1,28 @@ +#include +using namespace std; + +int main () { + int a,b; + char op; + cout << "Enter an equation: "; + cin >> a >> op >> b; + cout << a << op << b << " = "; + + if (op=='+'){ //Addition + cout << a + b; + } + + if (op=='-'){ //Subtraction + cout << a - b; + } + + if (op=='*'){ //Multiplication + cout << a * b; + } + + if (op=='/'){ //Division + cout << a / b; + } + + cout << endl; + } -- cgit v1.2.3