C++ code not compiling, help please/

This is a discussion on C++ code not compiling, help please/ within the C++ Programming forums, part of the General Programming Boards category; Hi I'm new to programming and I'm doing this project where I have to stimulate an ATM machine and do ...

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    5

    Post C++ code not compiling, help please/

    Hi I'm new to programming and I'm doing this project where I have to stimulate an ATM machine and do things the way they work, and I'm not supposed to use advanced functions we did not learn in class. It asks the user to input a letter to either withdraw, deposit or see balance or just quit, But it should keep asking until the user asks to quit which in this case is (Q,q). And for some reason, i get errors like expected unqualified-id before { token and expected , or ; before { token. I was wondering if anyone could help me with this, I really did try my best to work it out myself. Here is my C++ code, if anyone can help me I will be really grateful.

    [tag]
    Code:
    #include <iostream>
    #include <stdlib.h>
    
    
    using namespace std;
    
    void menu (void);
    
    int main()
    {
    
    
    float number,result;
    float numero = 5000.00;
    void menu (void);
    void check_balance(void);
    char choice;
    
    menu();
    cin >> choice;
    
    while(choice !='d' && choice != 'D' && choice != 'w' && choice != 'W' && choice != 'b' && choice != 'B' && choice != 'Q' && choice != 'q')
    {
    cout << "It's not a valid entry." << endl;
    menu();
    cin >> choice;
    
    
    }
    
    if (choice == 'd' || choice == 'D')
    {
    cout << "How much will you deposit?" << endl;
    cin >> number;
    }
    
    result = (number + numero);
    }
    else if (choice == 'w' || choice == 'W')
    {
    cout << "How much will you withdraw?" << endl;
    cin >> number;
    result = (numero - number);
    }
    
    else if (choice == 'b' || choice == 'B')
    {          
               
    void print_balance (void);
    
    cout << "Your balance is " << balance  << " dollars." << endl;
    }
    
    {
    else (choice == 'q' || choice == 'Q')
    
    return 0;
    }
    
    {
    cout << "Thank you for your transaction! Your current balance is now " << result  << " dollars." << endl;
    cout << "What would you like to do now?" << endl;
    
    return 0;
    }
    void menu(void);
    
    {       cout << "Hello there!" <<endl;
    cout << "Enter D or d for deposit." << endl;
    cout << "Enter W or w for withdrawal." << endl;
    cout << "Enter B or b for balance." << endl;
    cout << "Enter Q or q to quit." << endl;
    
    } 
    
    
    void print_balance(float);
    {
    
    if (balance == balance)
    {
                
     return 0;
     
    }
    
    else 
    {
         
    return 1;
    
    }
         
    }
    
    [/tag]
    These are the errors I get

    Code:
    C:\Users\owner\Desktop\HW5.cpp:39: error: expected unqualified-id before "else"
    C:\Users\owner\Desktop\HW5.cpp:39: error: expected `,' or `;' before "else"
    
    C:\Users\owner\Desktop\HW5.cpp:46: error: expected unqualified-id before "else"
    C:\Users\owner\Desktop\HW5.cpp:46: error: expected `,' or `;' before "else"
    C:\Users\owner\Desktop\HW5.cpp:54: error: expected unqualified-id before '{' token
    C:\Users\owner\Desktop\HW5.cpp:54: error: expected `,' or `;' before '{' token
    C:\Users\owner\Desktop\HW5.cpp:60: error: expected unqualified-id before '{' token
    C:\Users\owner\Desktop\HW5.cpp:60: error: expected `,' or `;' before '{' token
    C:\Users\owner\Desktop\HW5.cpp:68: error: expected unqualified-id before '{' token
    C:\Users\owner\Desktop\HW5.cpp:68: error: expected `,' or `;' before '{' token
    C:\Users\owner\Desktop\HW5.cpp:78: error: expected unqualified-id before '{' token
    C:\Users\owner\Desktop\HW5.cpp:78: error: expected `,' or `;' before '{' token
    Last edited by KidFlash; 12-22-2010 at 05:31 PM.

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    I did not attempt to compile your code, and you did not provide the line number in error, so I'm ignoring your request for help.

    As a side note, if you fixed your indentation, you'll see your current logic is not correct. (I say optimistically)
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  3. #3
    Registered User
    Join Date
    Dec 2010
    Posts
    5

    Post

    Quote Originally Posted by Dino View Post
    I did not attempt to compile your code, and you did not provide the line number in error, so I'm ignoring your request for help.

    As a side note, if you fixed your indentation, you'll see your current logic is not correct. (I say optimistically)
    Okay I added the line errors for the compile log. And what logic.......?

  4. #4
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by KidFlash View Post
    Okay I added the line errors for the compile log. And what logic.......?
    "What logic"? exactly! No logic; in your indentation and brace-usage at least! Indent your code and see for yourself!

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    There is a difference between
    Code:
    void menu(void) {
    and
    Code:
    void menu(void); {

  6. #6
    Registered User
    Join Date
    Dec 2010
    Posts
    5

    Post

    Quote Originally Posted by tabstop View Post
    There is a difference between
    Code:
    void menu(void) {
    and
    Code:
    void menu(void); {
    Soooooo....which one is right? Guys I'm a total newbie at programming I'm not used to actually using computer logic or your terminology. . . .

  7. #7
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by KidFlash View Post
    Soooooo....which one is right? Guys I'm a total newbie at programming I'm not used to actually using computer logic or your terminology. . . .
    Gee. Which one has the errors, and which one works (i.e., line 9 has a function on it, and there's no errors there....)?

  8. #8
    Registered User
    Join Date
    Dec 2010
    Posts
    5

    Post

    Quote Originally Posted by tabstop View Post
    Gee. Which one has the errors, and which one works (i.e., line 9 has a function on it, and there's no errors there....)?
    There is no errors in int main ()

  9. #9
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by KidFlash View Post
    There is no errors in int main ()
    I'd say that kind of strengthens his point rather than weakening it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code Blocks compiling problem
    By Lehsyrus in forum Tech Board
    Replies: 2
    Last Post: 07-13-2010, 03:28 PM
  2. Source code not compiling...
    By darren78 in forum C++ Programming
    Replies: 6
    Last Post: 11-23-2009, 07:53 AM
  3. loop and compiling inside a code
    By MtJ in forum C Programming
    Replies: 3
    Last Post: 03-05-2006, 12:50 PM
  4. Replies: 1
    Last Post: 03-01-2006, 03:07 AM
  5. compiling c code
    By MadCow257 in forum C++ Programming
    Replies: 2
    Last Post: 02-16-2006, 09:26 AM

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