Like Tree2Likes
  • 2 Post By Salem

C++ error

This is a discussion on C++ error within the C++ Programming forums, part of the General Programming Boards category; Can anyone give me a hand with these errors? Code: #include <iostream> using namespace std; int main() { char lang; ...

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    1

    C++ error

    Can anyone give me a hand with these errors?

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        char lang;
        char type;
        char account;
        int pin;
        int attempt = 0;
        int balance = 3230;
        int balance2 = 6000;
        int request;
        cout << "Please Select your language" << endl;
        cout << "Enter E for English o S para español" << endl;
        cin >> lang;
            if ( lang==E || lang==e && attempt != 3){
            cout << "Please Enter your pin number" << endl;
            cin >> pin;
                if (pin = 15592){
                cout << "Success Accessing account" << endl;
                cout << "Enter S for Savings or C for Checking" << endl;
                cin >> type;
                    if (type=C || type=c)
                    {
                        cout << "Would you like to withdraw from your Checking or Deposit" << endl;
                        cout << "Enter W for Withdraw or D for Deposit" << endl;
                            if (account=w || account=W){
                            cout << "Enter the ammout you would like to withdraw" << endl;
                            cin >> request;
                                if (request > balance){
                                cout << "You do not have that much in your" << endl;
                                }
                                else {
                                request - balance;
                                cout << "You have withdrawn the funds from your account, your new account balance is: " << balance << endl;
                                cout << "Would you like to make another Transaction?" << endl;
                                cout << "Enter Y for yes or N for no." << endl;
                                }
                            else if(account==D || account==d)
                            {
                            cout << "Please Insert your money" << endl;
                            }
                            else {
                            cout << "You entered a letter other then W or D" << endl;
                            }
                    }
                    else if (type==S || type==s){
                    cout << "Would you like to withdraw from your Savings or Deposit" << endl;
                    cout << "Enter W for Withdraw or D for Deposit" << endl;
                        if (account=w || account=W){
                        cout << "Enter the ammout you would like to withdraw" << endl;
                        cin >> request;
                            if (request > balance2){
                            cout << "You do not have that much in your" << endl;
                            }
                            else {
                            request - balance2;
                            cout << "You have withdrawn the funds from your account, your new account balance is: " << balance2 << endl;
                            cout << "Would you like to make another Transaction?" << endl;
                            cout << "Enter Y for yes or N for no." << endl;
                            }
                        else if (account==D || account==d)
                        {
                        cout << "Please Insert your money" << endl;
                        }
                        else {
                        cout << "You entered a letter other then W or D" << endl;
                        }
                }
                else {
                cout << "That pin number is incorect" << endl;
                attempt =+ 1;
                    if (attempt==3){
                    cout << "Account locked out" << endl;
                    }
                }
           else if(lang=S || lang=s && attempt != 3){
                cout << "Por favor, introduzca su número de PIN" << endl;
                cin >> pin;
                if (pin = 15592) {
                cout << "El éxito acceder a la cuenta" << endl;
                cout << "Ingrese S para el ahorro o C para la Comprobación" << endl;
                cin >> type;
                    if (type = C | | type = c)
                    {
                        cout << "¿Le gustaría retirarse de su cuenta corriente o depósito" << endl;
                        cout << "Introduzca W para el Retiro o D para el Depósito" << endl;
                            if (account = w | | account= W) {
                            cout << "Introduzca el ammout que le gustaría retirarse" << endl;
                            cin >> request;
                                if (request > balance) {
                                cout << "Usted no tiene que gran parte de su" << endl;
                                }
                                else {
                                request - balance;
                                cout << "Se han retirado los fondos de su cuenta, el saldo de su nueva cuenta es:" << balance << endl;
                                cout << "¿Desea realizar otra transacción?" << Endl;
                                cout << "S para Sí o N para no." << Endl;
                                }
                            else if (account == D | | account == d) {
                            cout << "Inserte su dinero" << endl;
                            }
                            else {
                            cout << "Ha escrito una carta de otra entonces W o D" << endl;
                            }
                    }
                    else if (type == S | | type == s) {
                    cout << "¿Le gustaría retirarse de sus ahorros o de depósito" << endl;
                    cout << "Introduzca W para el Retiro o D para el Depósito" << endl;
                        if (account = w | | account = W) {
                        cout << "Introduzca el ammout que le gustaría retirarse" << endl;
                        cin >> request;
                            if (request > balance2) {
                            cout << "Usted no tiene que gran parte de su" << endl;
                            }
                            else {
                            request - balance2;
                            cout << "Se han retirado los fondos de su cuenta, el saldo de su nueva cuenta es:" << balance2 << endl;
                            cout << "¿Desea realizar otra transacción?" << Endl;
                            cout << "S para Sí o N para no." << Endl;
                            }
                        else if (account == D | | account == d) {
                        cout << "Inserte su dinero" << endl;
                        }
                        else {
                        cout << "Ha escrito una carta de otra entonces W o D" << endl;
                        }
                }
                else {
                cout << "Que el número de pin es incorrecto se" << endl;
                attempt =+ 1;
                    if (attempt == 3) {
                    cout << "Cuenta bloqueada" << endl;
                    }
                }
           else {
                cout << "You did not select E for English nor S for Spanish, Please Try again." << endl;
                cout << "No ha seleccionado E para Inglés, ni S para español, por favor intente de nuevo." << endl;
                }
    return 0;
    }
    Code:
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp||In function 'int main()':|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|18|error: 'E' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|18|error: 'e' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|21|warning: suggest parentheses around assignment used as truth value|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|25|error: 'C' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|25|error: 'c' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|29|error: 'w' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|29|error: 'W' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|36|warning: statement has no effect|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|41|error: expected '}' before 'else'|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|41|error: 'D' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|41|error: 'd' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|49|error: 'S' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|49|error: 's' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|52|error: 'w' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|52|error: 'W' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|59|warning: statement has no effect|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|64|error: expected '}' before 'else'|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|64|error: 'D' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|64|error: 'd' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|79|error: expected '}' before 'else'|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|79|error: 'S' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|79|error: 's' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|82|warning: suggest parentheses around assignment used as truth value|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|86|error: 'C' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|86|error: expected primary-expression before '|' token|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|86|error: 'c' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|90|error: 'w' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|90|error: expected primary-expression before '|' token|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|90|error: 'W' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|97|warning: statement has no effect|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|99|error: 'Endl' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|102|error: expected '}' before 'else'|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|102|error: 'D' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|102|error: expected primary-expression before '|' token|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|102|error: 'd' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|109|error: expected primary-expression before '|' token|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|112|error: 'w' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|112|error: expected primary-expression before '|' token|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|112|error: 'W' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|119|warning: statement has no effect|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|121|error: 'Endl' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|124|error: expected '}' before 'else'|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|124|error: 'D' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|124|error: expected primary-expression before '|' token|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|124|error: 'd' was not declared in this scope|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|138|error: expected '}' before 'else'|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|143|error: expected '}' at end of input|
    C:\Users\Jamin\Desktop\Citizens-test\atm2\main.cpp|143|error: expected '}' at end of input|
    ||=== Build finished: 42 errors, 6 warnings ===|

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,159
    At a glance, your various "'E' was not declared in this scope" kind of errors are due to the fact that you did not quote your character literals, e.g.,
    Code:
    if ( lang==E || lang==e && attempt != 3){
    should be:
    Code:
    if ( lang=='E' || lang=='e' && attempt != 3){
    Other than that, be careful of the relative precedence of || and &&, and of the difference between = and ==.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,761
    Yes, you should have pressed "compile" when your code looked like this.
    Code:
        cout << "Please Select your language" << endl;
        cout << "Enter E for English o S para español" << endl;
        cin >> lang;
        if ( lang==E || lang==e && attempt != 3){
        }
    1. If you only add a few lines, you can only get a few errors at most (rather than a couple of pages)
    2. If you do get errors, it's 99% certain it will be in the last lines you added since you last compiled successfully
    3. You won't end up copy/pasting broken code, and then having to fix it everywhere.

    Compile often, work your way through the message and repeat is how you get it done.

    Writing 100's of lines, then dumping it on a message board for someone else to fix when it has pages of errors is not a long term strategy.
    Elkvis and Elysia like this.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 11-28-2011, 11:48 AM
  2. Replies: 4
    Last Post: 07-24-2011, 10:38 PM
  3. Replies: 1
    Last Post: 11-15-2010, 11:14 AM
  4. Replies: 3
    Last Post: 10-02-2007, 10:12 PM
  5. Compiler error error C2065: '_beginthreadex; : undeclared identifier
    By Roaring_Tiger in forum Windows Programming
    Replies: 3
    Last Post: 04-29-2003, 02:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21