I redid the code again but this time I get an error c2061 identifier 'cout'. Someone explain to me this. I am pretty new with C++ I highly appreciate it.

#include <iostream>
#include <cmath> 
using namespace std;
const double pi = 3.14159265;

int main ()
{

    string name;  
    string homework; 

    name = "Randy Calhoun, Giannis Combe, Jonathan Vega";
    homework = "Project 1";

    cout << "Randy Calhoun, Giannis Combe, Jonathan Vega" << endl;
    cout << "Project 1" << endl;




    int index;
    double input1, input2, output; 
    bool quit, back, back2; 

    do

    cout << "0. Quit\n";
    cout << "1. Unit Conversions\n";
    cout << "2. Math Operations\n";
    cout << "3. Math Functions\n";
    quit = false; 
    cin >> index; 
    switch(index)
    {
    case 0: 
        quit = true; 
        break; 

    case 1: 

        cout << " 0. Back to Previous Menu\n"; 
        cout << " 1. From Inches to Meters\n"; 
        cout << " 2. From Meters to Inches\n"; 
        cout << " 3. From Kilograms to Pounds\n"; 
        cout << " 4. From Pounds to Kilograms\n";
        cout << " 5. From km/hr to mi/hr\n"; 
        cout << " 6. From mi/hr to ki/hr\n"; 
        cout << " 7. From Newtons to lbf\n"; 
        cout << " 8. From lbf to Newtons\n"; 
        cout << " 9. From Pa to PSI\n"; 
        cout << " 10. From PSI to Pa\n"; 
        back = false; 
        cin >> index; 
        switch (index) 
        {
        case 0: 
            back = true; 
            break; 

        case 1: 
            cout << "Convert inches to meters:\n"; 
            cin >> input1; 
            output = input1 * 25.4/1000;
            cout << "It equals " << output << "m\n"; 
            break; 

        case 2:   
            cout << "Convert meters to inches:\n"; 
            cin >> input2; 
            output = input2 * 1000/25.4;
            cout << "It equals " << output << "m\n"; 
            break; 

        case 3:   
            cout << "Convert kilograms to pounds:\n"; 
            cin >> input1; 
            output = input1 * 2.2;
            cout << "It equals " << output << "m\n"; 
            break; 

        case 4:
            cout << "Convert Pounds to Kilograms:\n"; 
            cin >> input2; 
            output = input2 / 2.2;
            cout << "It equals " << output << "m\n"; 
            break;  

        case 5:   
            cout << "Convert km/hr to mi/hr:\n"; 
            cin >> input1; 
            output = input1 / 1.609344;
            cout << "It equals " << output << "m\n"; 
            break; 

        case 6:
            cout << "Convert mi/hr to km/hr:\n"; 
            cin >> input2; 
            output =   input2 / 1.609344;
            cout << "It equals " << output << "m\n"; 
            break; 

        case 7:   
            cout << "Convert Newtons to lbf:\n"; 
            cin >> input1; 
            output = input1 / 4.44822;
            cout << "It equals " << output << "m\n"; 
            break;

        case 8:
            cout << "Convert lbf to Newtons:\n"; 
            cin >> input2; 
            output = input2 * 4.44822;
            cout << "It equals " << output << "m\n"; 
            break; 

        case 9:
            cout << "Convert Pa to PSI:\n"; 
            cin >> input1; 
            output = input1 / 6,894.75729;
            cout << "It equals " << output << "m\n"; 
            break; 

        case 10:
            cout << "Convert PSI to Pa:\n"; 
            cin >> input2; 
            output = input2 * 6,894.75729;
            cout << "It equals " << output << "m\n"; 
            break; 


        default:
            cout << "Enter an option\n";
            break;
        }while (back != true); 
        break;

    case 2:
        int index, c, b, a;

        do
        {

            cout << " 0. Back to Previous Menu\n"; 
            cout << " 1. Calculations for +\n"; 
            cout << " 2. Calculations for -\n";
            cout << " 3. Calculations for *\n";
            cout << " 4. Calculations for /\n";
            cout << " 5. Calculations for %\n";
            back = false; 
            cin >> index; 
            switch (index) 
            {
            case 0: 
                back = true; 
                break; 

            case 1:
                cout << "How to calculate addition\n";
                cout << "Enter a number for a and b\n";
                c = a + b;
                cout << "The result is" << c << "\n";
                break;

            case 2:
                cout << "How to calculate subtraction\n";
                cout << "Enter a number for a and b\n";
                c = a - b;
                cout << "The result is" << c << "\n";
                break;

            case 3:
                cout << "How to calculate multiplication \n";
                cout << "Enter a number\n";
                c = a * b;
                cout << "The result is" << c << "\n";
                break;

            case 4:
                cout << "How to calculate division\n";
                cout << "Enter a number\n";
                c = a / b;
                cout << "The result is" << c << "\n";
                break;
            case 5:
                cout << "How to calculate Remainder\n";
                cout << "Enter a number\n";
                c = a % b;
                cout << "The result is" << c << "\n";
                break;
            }
        }while(back != true); 

        break;

    case 3:
        int i;
        double n, x, y, result;

        cout << " 0. Back to Previous Menu\n"; 
        cout << " 1. Calculations for Absolute Value\n"; 
        cout << " 2. Calculations for Square Root\n";
        cout << " 3. Calculations for powers\n";
        cout << " 4. Calculations for exponential\n";
        cout << " 5. Calculations for Logarithms\n";
        cout << " 6. Calculations for Log base ten\n";
        cout << " 7. Calculations for Sine\n";
        cout << " 8. Calculations for Cosine\n";
        cout << " 9. Calculations for Tangent\n";
        cout << " 10. Calculations for Arcsine\n";
        cout << " 11. Calculations for Arccosine\n";
        cout << " 12. Calculations for Arctangent\n";
        cout << " 13. Calculations for Arctangent2\n";
        cout << " 14. Calculations for Sinh\n";
        cout << " 15. Calculations for Cosh\n";
        cout << " 16. Calculations for Tanh\n";
        cout << " 17. Calculations for Ceil\n";
        cout << " 18. Calculations for Floor\n";


        do
        {
            cin >> i;       
            switch(i)
            {
            case 0: 
                back = true; 
                break;

            case 1:
                cout << "Calculations for Absolute value\n";
                cout << " Enter a number\n";
                result = fabs(n);
                cout << "The result is" << result << "\n";
                break;

            case 2:
                cout << "Calculations for Square Roots\n";
                cout << "Enter a number\n";
                result = sqrt(n);
                cout << "The result is" << result << "\n";
                break;

            case 3:
                cout << "Calculations for powers\n";
                cout << "Enter a number\n";
                result = pow(n,x);
                cout << "The result is" << result << "\n";
                break;

            case 4:
                cout << "Calculations for exponential\n";
                cout << "Enter an exponential value\n";
                result = exp(n);
                cout << "The result is" << result << "\n";
                break;

            case 5:
                cout << "Calculations for Logarithms\n";
                cout << "Enter a number\n";
                result = log(n);
                cout << "The result is" << result << "\n";
                break;

            case 6:
                cout << "Calculations for Log base ten\n";
                cout << "Enter a number\n";
                result = log10(n);
                cout << "The result is" << result << "\n";
                break;

            case 7:
                cout << "Calculations for Sin\n";
                cout << "Enter a number\n";
                result = sin (n * pi / 180);
                cout << "The result is" << result << "\n";
                break;

            case 8:
                cout << "Calculations for Cosine\n";
                cout << "Enter a number\n";
                result = cos (n * pi / 180);
                cout << "The result is" << result << "\n";
                break;

            case 9:
                cout << "Calculations for Tangent\n";
                cout << "Enter a number\n";
                result = tan(n * pi / 180);
                cout << "The result is" << result << "\n";
                break;

            case 10:
                cout << "Calculations for Arcsine\n";
                cout << "Enter a number\n";
                result = asin(n) * 180.0 / pi;
                cout << "The result is" << result << "\n";
                break;

            case 11:
                cout << "Calculations for Arccosine\n";
                cout << "Enter a number\n";
                result = acos(n) * 180.0 / pi;
                cout << "The result is" << result << "\n";
                break;

            case 12:
                cout << "Calculations for Arctangent\n";
                cout << "Enter a number\n";
                result = atan(n) * 180.0 / pi;
                cout << "The result is" << result << "\n";
                break;

            case 13:
                cout << "Calculations for Arctangent2\n";
                cout << "Enter a number\n";
                result = exp(n);
                cout << "The result is" << result << "\n";
                break;

            case 14:
                cout << "Calculations for Sinh\n";
                cout << "Enter a number\n";
                result = sinh(n);
                cout << "The result is" << result << "\n";
                break;

            case 15:
                cout << "Calculations for Cosh\n";
                cout << "Enter a number\n";
                result = cosh(n);
                cout << "The result is" << result << "\n";
                break;

            case 16:
                cout << "Calculations for tanh\n";
                cout << "Enter a number\n";
                result = tanh(n);
                cout << "The result is" << result << "\n";
                break;

            case 17:
                cout << "Calculations for ceil\n";
                cout << "ceil of a number is\n" << n;
                break;

            case 18:
                cout << "Calculations for floor\n";
                cout << "floor of a number is\n" << n;
                break;

                break;
            default:
                cout << "Enter any of the options\n";
                break;
                }
        }while (quit != true);

        system ("pause");
        return 0;
    }
    }

Recommended Answers

All 2 Replies

You're missing the open brace { for the start of the do loop (line 25).

The only thing I can imediately see is that there's a 'do' at line 25 with no opening brace and no corresponding while statement further down in the code. I imagine the cout at line 27 is where the error is being thrown. And this is almost certainly because of the rogue do statement at line 25.
Either remove the do, or enclose the code after the do and put a corresponding while statement later in the code. That should clear that error!

There may be some other gotchas in your code, but I haven't looked at it in any great detail yet!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.