Basic Fully Functional Calculator

Jun 5, 2012 at 11:28am
For all beginners and 12-year olds out there (just like me, 12 years old)...
I just developed this simple calculator, which adds, subtracts, multiplies and divides.

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
#include <iostream>
#include <cmath>
using namespace std;
int main(){
   double num1;
   double num2;
   double answer;
   string choice;
   cout << "What operation do you want?" << endl;
   cout << "Just type: ADD, SUBTRACT, MULTIPLY or DIVIDE in all caps!" << endl << endl;
   cin >> choice;
   system("cls");
   cout << "Enter a number: ";
   cin >> num1;
   cout << "Enter another number: ";
   cin >> num2;
   cout << endl << endl;
   if(choice=="ADD"){
      answer = num1 + num2;
      cout << "The sum is: " << answer << endl;
      system("pause");
      return 0;
   }
   if(choice=="SUBTRACT"){
      answer = num1 - num2;
      cout << "The difference is: " << answer << endl;
      system("pause");
      return 0;
   }
   if(choice=="MULTIPLY"){
      answer = num1 * num2;
      cout << "The product is: " << answer << endl;
      system("pause");
      return 0;
   }
   if(choice=="DIVIDE"){
      answer = num1 / num2;
      cout << "The quotient is: " << answer << endl;
      system("pause");
      return 0;
   }
}


Hope you all guys like it!
Jun 5, 2012 at 12:39pm
Very basic, but a good program for beginners. I feel like we all made that exact program at one point!
Jun 5, 2012 at 4:01pm
hmmm good.
very basic but you are only 12 years old so this is very good program.
keep it up
Jun 5, 2012 at 4:38pm
closed account (zb0S216C)
omeraslam wrote:
"you are only 12 years old so this is very good program."

As I've said before, age has nothing to do with it. And because he/she's young, it's automatically a good program? I'm not knocking xcalibur0645 or his/her code; I'm just saying.

Wazzak
Jun 5, 2012 at 5:27pm
^^ Shouldn't he be programming for a droid or something? :)
Topic archived. No new replies allowed.