Basic Arithmetic Calculator

Hi! I'm new to C++. I have a basic calculator I have to make which requires the user to input to values and choose from the options (A-D and Q *for quit*) what action they want done with those numbers. The program must loop continuously until the user decides to quit.

The issue I'm having is I keep getting the following error for all five options:
error 'A' (or one of the other letters) was not declared in this scope

Please give me advice on how to fix this so that my option choices are declared.




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
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
using namespace std;
int number1, number2, choice, total; 
int main()
{



   cout << "Please enter two numbers: ";
   	cout << "Input number 1: ";
	cin >> number1;
	cout << "Input number 2: ";
	cin >> number2;


   cout<< "What would you like to do with those numbers? Your options are:\n "
    << "A Addition \n" <<
       "B Subtraction \n" <<
       "C Multiply \n" <<
       "D Divide \n" <<
       "Q Quit \n";
       cin >> choice;


switch(choice)
       {

    case A:
    total = number1+ number2;
    cout << "Your total is " << result << "\n\n";
    break;
    case B:
    total = number1- number2;
    cout << "Your total is " << result << "\n\n";
    break;
    case C:
    total = number1* number2;
    cout << "Your total is " << result << "\n\n";
    break;
    case D:
    total = number1/ number2;
    cout << "Your total is " << result << "\n\n";
    break;


       }

 if(choice == Q) break;
}

return 0;

}

   


closed account (48T7M4Gy)
try case 'A' etc
Also you need to declare int result
Thanks Kemort!!
Topic archived. No new replies allowed.