-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimpleCalculator.cpp
More file actions
45 lines (35 loc) · 1020 Bytes
/
simpleCalculator.cpp
File metadata and controls
45 lines (35 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
double sum(double a, double b){
return a+b;
}
double subtract(double a, double b){
return a-b;
}
int main(){
//initializing the numbers and the operator
double a = 0;
double b = 0;
std::string oper;
std::cout << "Welcome to the Calculator!\n";
std::cout << "--------------------------\n";
std::cout << "Currently available operations are:\n";
//Print out current operations here.
std::cout << "1: Summation: +\n";
std::cout << "2: Subtract: -\n";
std::cout << "Please enter the first numero\n";
std::cin >> a;
std::cout << "Enter the operation por favor\n";
std::cin >> oper;
std::cout << "Enter the second number SVP\n";
std::cin >> b;
double result = 0;
if (oper == "+"){
result = sum(a,b);
}
else if(oper == "-"){
result = subtract(a,b);
}
std::cout << "Result to your operation:\n";
std::cout << a << " " << oper << " " << b << " = " << result;
std::cout << "\n";
}