Calculator program, error received "no match for 'operator>>'

It has been years since I took C++ in college, so when my manager asked me to work on a project in C++ I decided I needed a refresher course. I found one online and got stuck on a simple calculator program. I believe I entered the code exactly as in the example, but receive the following error:

error: no match for 'operator>>' (operand types are 'std::basic_ostream<char>::__ostream_type {aka std::basic_ostream<char>}' and 'double')|

This is happening on the line of code that says "cin >>number_1;"

I have reviewed the forum and searched online for a solution. Most of the online resources I found imply this error means number_1 has not been properly declared, but I did declare it at the beginning of the code as "double number_1;"

I am sure I have made a simple mistake, but can't seem to figure this one out. Here is the relevant section of the code. Thank you in advance for any help.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  int choice;
    double number_1;
    double number_2;
    cout<<"1.) Addition"<<endl;
    cout<<"2.) Subtraction"<<endl;
    cout<<"3.) Multiplication"<<endl;
    cout<<"4.) Division"<<endl;
    cout<<endl<<endl<<"Enter a choice: ";
    cin>>choice;
    switch(choice){
case 1:
    {
    cout<<"Enter first number:"<<
    cin >>number_1;
    cout<<endl<<endl<<"Enter second number:"<<
    cin>>number_2;
    cout<<endl<<endl<<endl;
    cout<<"The sum is "<<number_1+number_2;
     break;
    }
line 13 etc should not have << at the end.

cout<<"Enter first number:"; //<<
Wow, that was easy! Thanks a bunch.
This runs:
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
#include <iostream>

using namespace std;

int main()
{
    int choice;
    double number_1;
    double number_2;
    
    cout<<"1.) Addition"<<endl;
    cout<<"2.) Subtraction"<<endl;
    cout<<"3.) Multiplication"<<endl;
    cout<<"4.) Division"<<endl;
    cout<<endl<<endl<<"Enter a choice: ";
    cin>>choice;
    switch(choice)
    {
        case 1:
        {
            cout<<"Enter first number:"; // << <--
            cin >> number_1;
            cout<<endl<<endl<<"Enter second number:"; // <<
            cin>>number_2;
            cout<<endl<<endl<<endl;
            cout<<"The sum is "<<number_1+number_2;
            break;
        }
            
    }
    
    return 0;
}

1.) Addition
2.) Subtraction
3.) Multiplication
4.) Division


Enter a choice: 1
Enter first number:22


Enter second number:22



The sum is 44Program ended with exit code: 0
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
57
58
59
60
61
62
#include <iostream>

using namespace std;

int main()
{
    int choice;
    double number_1;
    double number_2;
    
    cout<<"Enter first number: ";
    cin >> number_1;
    
    cout << "Enter second number: ";
    cin>>number_2;
    
    cout
    << '\n'
    << "1.) Addition\n"
    << "2.) Subtraction\n"
    << "3.) Multiplication\n"
    << "4.) Division\n\n"
    << "Enter a choice: ";
    
    cin>>choice;
    switch(choice)
    {
        case 1: // ADD
        {
            cout << '\n' << "The sum is " << number_1 + number_2 << '\n';
            break;
        }
        case 2: // SUBTRACT
        {
            cout << '\n' << "The difference is " << number_1 - number_2 << '\n';
            break;
        }
            
        case 3: // MULTIPLY
        {
            cout << '\n' << "The product is " << number_1 * number_2 << '\n';
            break;
        }
            
        case 4: // DIVIDE
        {
            if(number_2 != 0)
                cout << '\n' << "Division gives " << number_1 / number_2 << '\n';
            else
                cout << "Division by zero\n";
            break;
        }
            
        default:
        {
            cout << '\n' << "Nothing specified for {" << number_1 << ' ' << number_2 << "}\n";
            break;
        }
    }
    
    return 0;
}
Topic archived. No new replies allowed.