pin number question

This is a discussion on pin number question within the C Programming forums, part of the General Programming Boards category; ok, corrected those mistakes which, as usual for me, found other errors earlier in the code. Code: #include <stdio.h> #include ...

  1. #16
    Registered User
    Join Date
    Sep 2004
    Posts
    18
    ok, corrected those mistakes which, as usual for me, found other errors earlier in the code.

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>
    
    /*Prototype Declarations*/
    float fastcash   (float bal, float fwith);
    float Withdraw   (float bal, float with);
    float Deposit    (float bal, float dep);
    void  balinq     (float bal);
    void  endtrans   (void);
    int   mainchoice (void);
    float bal;
    
    
    
    
    
    int main(void)
    {
        /*Local Definitions*/
        int     count = 0;
        char    pin[4];
        float   bal = 1000;    
        int     dep;
        int     with;
        int     choice;
        int     check = 0;
          
            
            
        /*Statements*/
        
        printf("\tWelcome to the COP2220 ATM");
        printf("\n\t Please enter your 4 digit PIN \n ");
          scanf("%c", &pin);
          
                
                if (strlen(pin) != 4)
                      printf("\a\nThat PIN is incorrect. Please re-enter your 4 digit PIN \n");
                      ++count;
                if (count == 3)                              /*error occurs here*/
                      void endtrans (void);    
                              
        
                int mainchoice (choice);
                 if (mainchoice == 1)
                    float fastcash  (float bal);
                 else if (mainchoice == 2)
                    float withdraw  (float bal);
                 else if (mainchoice == 3)      
                    float deposit   (float bal);
                 else if (mainchoice == 4)                            
                    float balinq    (void);
                 else
                    void endtrans   (void);
                 return 0;
      }    
          
          /*==================================Mainchoice===========================
                This function asks the user to select which type of transaction he/she wants
                to make.
          */
          int mainchoice (void)
    {
          /*Local Definitions*/
          int choice;
          
          /*Statements*/
          printf("\n\tPlease make a selection from the list below and hit Return:");
          
          
          
          printf("\n\t*****************************");
          printf("\n\t*           MENU            *");
          printf("\n\t*                           *");
          printf("\n\t*   1. Fast Cash            *");
          printf("\n\t*   2. Withdrawal           *");
          printf("\n\t*   3. Deposit              *");      
          printf("\n\t*   4. Balance Inquiry      *");           
          printf("\n\t*   5. End Transaction      *"); 
          printf("\n\t*                           *");
          printf("\n\t*****************************");
          
          scanf("%d", &choice);
          return choice;
    }     /*mainchoice*/    
          
                                                      
                                                                            
       
            
          /*============================Fast Cash================================
                Asks the user to select from a list of withdrawal amounts.  The 
                amount is then subtracted from the balance.
          */
          
          float FastCash (float bal,
                          int fwith)
          
          
      {    /*Statements*/
          
          printf("\n\tPlease select the amount of money you would like to withdraw:");
          
          switch (fwith)
                {
                      case 1:  printf("$20.00\n");
                               break;
                      case 2:  printf("$40.00\n");
                               break;
                      case 3:  printf("$80.00\n");
                               break;
                      case 4:  printf("$100.00\n");
                               break;
                      case 5:  printf("Main Menu\n");
                               break;  
                }    
                bal = bal - fwith;
                
    }/*fastcash*/            
                
                
                
                
          /*============================Withdrawal================================
                Asks the user to enter the amount of money to be withdrawn.  The amount
                is then subtracted from the balance.
          */
          float Withdraw (int with,
                          float bal)
          {
           /*Statements*/   
                 printf("Please enter the amount of money you would like to withdraw: \n");
                 scanf("%f", &with);
                 bal = bal - with;
                 return bal;
      }    /*Withdrawal*/
      
      
      
      
      
          
          /*==============================Deposit==================================
                Asks the user to enter the amount of money to be deposited.  The amount
                is then added to the balance.
          */
          float Deposit (float bal,
                         float dep)
          {
            /*Statements*/  
                  printf("Please enter the amount of money you would like to deposit: \n");
                  scanf("%f", &dep);
                  bal = bal + dep;
                  return bal;
         }  /*Deposit*/
          
          
          
          
          
          
          /*==============================BalInq============================
                Prints the users current balance.
          */
          
          void balinq (float bal)
          {
              /*Statements*/
                    printf("\n\tYour current balance is: %f", bal);
                    return;
          }/*BalInq*/
      
      /*==================================endtrans===================================
                This function ends the transaction either at the request of the user or 
                when the incorrect PIN is entered too many times.
          */
          void endtrans (void)
          {
          /*Statements*/
                printf("\n\t Goodbye!");
                      return;
          }/*endtrans*/    
        
      
      
      system("PAUSE");	
      return 0;
    }
    I'm getting a "parse error before 'void' " error. For the record (because I'm new...what exactly is a parse error?

    melee

  2. #17
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    > if (mainchoice == 1)
    > float fastcash (float bal);

    Based on you definition of FastCash(), your call should look like:
    Code:
    bal = FastCash(bal);
    Also, you don't need the second parameter (fwith). Finally, you didn't return anything from FastCash().

    All you function calls need to be modified to look similar to the above call to FastCash.
    Last edited by swoopy; 12-10-2004 at 11:16 PM.

  3. #18
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,701
    >> scanf("%c", &pin);

    read this

    the two main problems with your code are:
    - incorrect syntax in invoking functions
    - passing variables that are modified in functions by value instead of as pointers

    I'd recommend you go back to your book and review those two things before you do anything else with the code.
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

  4. #19
    Registered User
    Join Date
    Sep 2004
    Posts
    18
    Ok, so I think I see what you're saying. Unfortunately, the book that my professor has chosen as a textbook isn't very user friendly. While that won't keep me from learning what I need to, it does slow me down a bit. I'll re-read. However, nobody answered my previous question. What exactly is a parse error? Knowing what it is might help me determine why I'm getting one.

  5. #20
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,701
    >> What exactly is a parse error?

    it's a syntax error such as unmatched braces, missing semicolens, incorrect declarations, etc, etc.
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. memory issue
    By t014y in forum C Programming
    Replies: 2
    Last Post: 02-20-2009, 11:37 PM
  2. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 10:13 AM
  3. Issue w/ Guess My Number Program
    By mkylman in forum C++ Programming
    Replies: 5
    Last Post: 08-23-2007, 01:31 AM
  4. help with number menu
    By j4k50n in forum C Programming
    Replies: 12
    Last Post: 04-17-2007, 01:33 AM
  5. Question about limiting the number of user inputs in C
    By chobibo in forum C Programming
    Replies: 15
    Last Post: 08-30-2006, 12:37 AM

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