Thread: C Programming Assignment Help!! (Cant Figure Out My Errors) :(

  1. #1
    Banned
    Join Date
    Apr 2011
    Location
    Santry, Ireland
    Posts
    29

    C Programming Assignment Help!! (Cant Figure Out My Errors) :(

    So this is my code and the errors are at the bottom, i cant figure them out for the life of me, ino there is probably more but i want to get these sorted first...its a banking database i have to create for next tues...help plz!!

    inset
    Code:
    #include<stdio.h>
    #include<conio.h>
    #define MAX_PERSONS 50
    
    /* Assignment 3A (55 Marks Needed)
        Write a Program To Create A Banking Database */
        
    /* Declaration Of Structures */
    
    
    struct acc_type
    {
    char name[50];
    float balance;
    };
    struct acc_type account[20];
    int number;
    int current;
    
    typedef struct acc_type ACC_TYPE;
    
    
    struct date 
    {
        int day;
        int month;
        int year;
    };
    
    
    typedef struct date DATE;
    
    
        
    struct personnel
    {
        int number;
        int phone_number;
        int age;
        char occupation[25];
        char surname[25];
        char first_name[10];
        char Address[30];
        char gender;
        DATE dob;
    };
    typedef struct personnel CUSTOMER;
        
    
    /* Function Prototypes */
    
    void add_a_customer(CUSTOMER []);
    void delete_a_customer(CUSTOMER []);
    void edit_a_customer(CUSTOMER []);
    void add_money_to_account(CUSTOMER []);
    void withdraw_money_from_account(CUSTOMER []);
    void display_a_customer(CUSTOMER []);
    void display_customer_details(CUSTOMER *);
    void apply_for_overdraft(CUSTOMER []);
    void init_database(CUSTOMER []);
    int  search_database(CUSTOMER [], int);
    int  menu(void);
    
    /* Main Program Scope */
    
    void main()
    
    {
        CUSTOMER persons[MAX_PERSONS];
        int menu_choice;
        
        init_database(persons);
        
        do
        {
            menu_choice = menu();
            switch ( menu_choice )
            {
                case 1 : add_a_customer(persons);
                         break;
                
                case 2 : delete_a_customer(persons);
                         break;
                
                case 3 : edit_a_customer(persons);
                         break;
                    
                case 4 : add_money_to_account(persons);
                         break;
                
                case 5 : withdraw_money_from_account(persons);
                         break;
                
                case 6 : apply_for_overdraft(persons);
                         break;
                
                case 7 : search_database(persons);
                         break;
                
                case 8 : display_customer_details(persons);
                         break;
            }
            
        }
        while ( menu_choice != 0);
         
        }
        
         /* Menu Display */
    
    
    
            /*------------------------------------------------------------------------------------/     
                    | Function: Display A Menu                                                                     |
                    |                                                                                                            |
                    | Purpose: Display A Menu For The Customer To Make A Choice              |
                    |                                                                                                            |
                    | Arguements: Calls A Function When Choice Is Made                             |
                    |--------------------------------------------------------------------------------------*/
        
        
        int menu(void)
        {
            int choice;
           
            /*Display the menu to the user*/
            printf("1.  Add an account.\n\n");
            printf("2.  Delete an account.\n\n");
            printf("3.  Edit an account.\n\n");
            printf("4.  Add money into an account\n\n");
            printf("5.  Withdraw money from an account\n\n");
            printf("6.  Apply for an overdraft\n\n");
            printf("7.  Search the database\n\n");
            printf("8.  Display customer details\n\n");
            printf("0.  End program.\n\n");
           
            do
            {
                scanf("%d",&choice);
                fflush(stdin);
            } while( choice < 0 || choice > 9 );
           
            return choice;
        }
        
         /* Case 1 */
        
            /*------------------------------------------------------------------------------------/
                    | Function: Add A Customer                                                                    |
                    |                                                                                                            |
                    | Purpose: Add A Customer To The Banking System                                 |
                    |                                                                                                            |
                    | Arguements: A Pointer To The Customer Array                                     |
                    |--------------------------------------------------------------------------------------*/
        
        void add_a_customer(CUSTOMER person_array[]) 
        {
            int i=0;
            
            /*Search The Array For Empty Slot.
                        An Empty Slot = 0                        */
            
            while ( person_array[i]. number !=0 && i < MAX_PERSONS )
                if ( i == MAX_PERSONS)
                    printf(" Unfortunatly The Database Is Full!!\n");
                else                                                   /* Add To Database */
                {
                    printf("\n\n Customer Number (1 To 4 Digits, Except 0) : ");
                    do
                        scanf( "%3d",&person_array[i].number);
                    while (person_array[i].number<=0);
                        
                    
                    /*Customer Details Gender */
                    printf("\n Customer Gender : " );
                    scanf ("%7s",person_array[i].gender);
                    
                        
                    /*Customer Details Name */
                    printf("\n Customer Surname (Maximum 25 Characters) : " );
                    scanf ("%25s",person_array[i].surname);
                    printf("\n First Name (Maximum 10 Characters) : " );
                    scanf ("%25s",person_array[i].first_name);
                    
                    /*Customer Details Date Of Birth */
                    
                    printf("\nDate Of Birth\n" );
                    printf("    Day (1 Or 2 Digits) ; ");
                    scanf ("%2d",&person_array[i].dob.day);
                    printf("    Month (1 Or 2 Digits ; ");
                    scanf ("%2d",&person_array[i].dob.month);
                    printf("    Year (1 Or 2 Digits ; ");
                    scanf ("%2d",&person_array[i].dob.year);
                    
                    /*Customer Details Occupation */
                    
                    printf("\nJob:");
                    scanf("%20s",person_array[i].occupation);
                    
                    /*Customer Details Address */
                    printf("House Number :  ");
                    printf("    House (1 - 3 Digits) ; ");
                    scanf ("%2d",&person_array[i].Address.house_number);
                    printf("Street Name :  ");
                    scanf ("%25s",&person_array[i].Address.street);
                    printf("City :  ");
                    scanf ("%15s",&person_array[i].Address.city);
                        
                    /*Customer Details Phone Number */    
                    printf("Phone Number :  ");
                    printf("Phone (7 Or 10 Digits) ; ");
                    scanf ("%10s",&person_array[i].phone_number);
                    
                }
                
            }
            
        /* Case 2 */
            
            /*------------------------------------------------------------------------------------/
                    | Function: Delete A Customer                                                                |
                    |                                                                                                            |
                    | Purpose:Delete A Customer From The Banking System                           |
                    |                                                                                                            |
                    | Arguements: A Pointer To The Customer Array                                     |
                    |--------------------------------------------------------------------------------------*/
                    
            void delete_a_customer(CUSTOMER person_array[])
            
            {
                int CUSTOMER_number;
                int pos;
                
            /* A Customer Is Deemed Deleted By Placing A 0 In The Customer Number */
                
            /* First The Customer Number Has To Be Obtained */
            printf(" Please Enter Your Personal Number : ");
            do
                            
            scanf("%10d",&CUSTOMER_number);
            while(CUSTOMER_number <= 0 );
               
            pos = search_database(person_array,CUSTOMER_number);
           
            if(pos == MAX_PERSONS)                    /* Yes */          
                printf("This Customer is not in the database\n");
            else                                      /* No */          
            {
                printf("Customer Account number %10d is deleted.\n",CUSTOMER_number);
                person_array[pos].number == 0;
            }
        }
        
        
        /* Case 3 */
        
            /*------------------------------------------------------------------------------------/
                    | Function: Edit A Customer                                                                   |
                    |                                                                                                           |
                    | Purpose: Edit A Customer From The Banking System                            |
                    |                                                                                                           |
                    | Arguements: A Pointer To The Customer Array                                     |
                    |--------------------------------------------------------------------------------------*/
        
            {
                
            int account_number;
            int pos;
        
            printf("Customer Account Number to edit: ");
            do
            scanf("%d",&account_number);
            while(account_number <=0 || account_number > SIZE);
            
            pos = deletion_search(customer, account_number);
            
            if(pos==SIZE)
            printf("This customer is not in the database\n");
            else
            {
                  /* Customer Name */
            printf("\n\nCustomer Surname (Up to 25 letters): ");
            scanf("%25s",customer[pos].surname);
                
            printf("\nFirst Name (Up to 10 letters): ");
            scanf("%10s",customer[pos].first_name);
                
                  /* Customer Date Of Birth */  
            printf("\nDate of Birth\n");
            printf("\nDay (1-31): ");
            scanf("%d",&customer[pos].dob.day);
            printf("\nMonth (1-12): ");
                
            scanf("%2d",&customer[pos].dob.month);
            printf("\nYear (2 digits i.e. 1990 is 90): ");
            scanf("%2d",&customer[pos].dob.year);
                
            printf("\nOverdraft Taken (Yes or No): ");
                
            scanf("%3s",customer[pos].overdraft);
            
               
            printf("\nBalance: ");
            scanf("%d",&customer[pos].balance);
            printf("\n\n");
            
            }
        
        }
    
        /* Case 4 */
    
            /*------------------------------------------------------------------------------------/
                    | Function: Add Money To An Account                                                   |
                    |                                                                                                           |
                    | Purpose: Add Money To A Customers Account                                      |
                    |                                                                                                           |
                    |                                                                                                           |
                    |--------------------------------------------------------------------------------------*/
    
    
    
            void add_money_to_account()
    
            {
                
            float add_sum;
            char dummy;
                
            printf("\nThe current balance for %s is %c%4.2f",account[current].name,156,
            account[current].balance);
                
            printf("\nHow much do you want to add to the account? %c",156);
            dummy=getch(); /* Clear Out Input Buffer */
                
            scanf("%f",&add_sum);
            if(add_sum < 0)
            {
            printf("\nNo negative sums allowed here");
            return;
            }
            account[current].balance += add_sum;
            printf("\nThe new balance is %c%4.2f",156,account[current].balance);
            return;
            }
    
    
            /* Case 5 */
    
            /*------------------------------------------------------------------------------------/
                    | Function: Withdraw Money From An Account                                      |
                    |                                                                                                           |
                    | Purpose: Withdraw Money From A Customers Account                         |
                    |                                                                                                           |
                    |                                                                                                            |
                    |--------------------------------------------------------------------------------------*/
    
                void withdraw_money_from_account()
            
            {
                
            float take_sum;
            char dummy;
                
            printf("\nThe current balance for %s is %c%4.2f",account[current].name,156,
            account[current].balance);
                
            if(account[current].balance == 0)
            {
                
            printf("\nThis account has zero balance - no overdraft facility!");
            return;
                
            }
            
            printf("\nHow much do you want to take from the account? %c",156);
            dummy=getch();//clear out input buffer
            scanf("%f",&take_sum);
            
            if(take_sum < 0)
            {
                
            printf("\nNo negative sums allowed here");
            return;
                
            }
            
            if(take_sum > account[current].balance)
                
            {
                
            printf("\nInsufficient funds!");
            return;
                
            }
            
            account[current].balance -= take_sum;
            printf("\nThe new balance is %c%4.2f",156,account[current].balance);
            
            }
            
                    
                    
    
    
    
    /* Case 7 */
        
            /*------------------------------------------------------------------------------------/     
                    | Function: Search Database                                                                  |
                    |                                                                                                            |
                    | Purpose: Search Database For Customer                                               |
                    |                                                                                                            |
                    |                                                                                                            |
                    |--------------------------------------------------------------------------------------*/
        
            {
                
            int i =0;
    
            while (i<SIZE && customer[i].account_number != account_number)
            i++;
    
            return (i);
            
            }
        
    
            /* Case 8 */
        
            /*------------------------------------------------------------------------------------/
                    | Function: Display A Customer                                                               |
                    |                                                                                                            |
                    | Purpose: Display A Customer From The Banking System                         |
                    |                                                                                                            |
                    | Arguements: A Pointer To The Customer Array                                     |
                    |--------------------------------------------------------------------------------------*/
        
        void display_a_customer( CUSTOMER person_array )
        {
            int CUSTOMER_number;
            int pos;
        
            /* Get The Customer Number */
            printf(" Customer Number To Display ( 1-4 Digits, Except 0) :");
            do
                scanf("%3d",&CUSTOMER_number);
                while( CUSTOMER_number <= 0);
                    
                /* Find The Customer In The Database */
                pos = seacrh_database( person_array,CUSTOMER_number);
                
                /* Does The Customer Exist In The Databse */
                if ( pos == MAX_PERSONS) /* No */
                printf(" The Selected Customer Is Not In The Databse\n" );
                else                     /* Yes - Display The Details */
                    display_customer_details(&person_array[pos]);
            }
            
            /*------------------------------------------------------------------------------------/
                    | Function: Display A Customers Details                                                  |
                    |                                                                                                            |
                    | Purpose: Display A Customers Details From The Banking System            |
                    |                                                                                                            |
                    | Arguements: A Pointer To The Customers Details                                  |
                    |--------------------------------------------------------------------------------------*/
            
            void display_customer_details(CUSTOMER *ptr)
        {
            printf("\n\n");
            printf("Account number : %d\n",ptr->number);
            printf("Surname        : %s\n",ptr->surname);
            printf("Firstname      : %s\n",ptr->first_name);
            printf("Job            : %s\n",ptr->occupation);
            printf("Surname        : %s\n",ptr->surname);
            printf("Telephone      : %d\n",ptr->phone_number);
            printf("Date of Birth  : %2d/%2d/%2d\n",ptr->dob.day, ptr->dob.month, ptr->dob.year);
            
        }
        
    
        
    
        
    
    
    
    errors: 
    
    Error E2193 Assignment_original.c 97: Too few parameters in call to 'search_database(personnel *,int)' in function main()
    Error E2294 Assignment_original.c 203: Structure required on left side of . or .* in function add_a_customer(personnel *)
    Error E2294 Assignment_original.c 205: Structure required on left side of . or .* in function add_a_customer(personnel *)
    Error E2294 Assignment_original.c 207: Structure required on left side of . or .* in function add_a_customer(personnel *)
    Error E2040 Assignment_original.c 265: Declaration terminated incorrectly

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    If you post errors with line numbers, highlight them in the code you post so we don't go crazy trying to count 265 lines. Also, don't post your error messages inside the code tags, it makes them harder to find.

    It's int main(void), and return an int at the end, usually 0.

    Quote Originally Posted by irishfeeney92 View Post
    Error E2193 Assignment_original.c 97: Too few parameters in call to 'search_database(personnel *,int)' in function main()
    Code:
    int  search_database(CUSTOMER [], int);
    ...
                case 7 : search_database(persons);
    How many parameters in your declaration and how many in your call? Notice a problem?

    Error E2294 Assignment_original.c 203: Structure required on left side of . or .* in function add_a_customer(personnel *)
    Error E2294 Assignment_original.c 205: Structure required on left side of . or .* in function add_a_customer(personnel *)
    Error E2294 Assignment_original.c 207: Structure required on left side of . or .* in function add_a_customer(personnel *)
    Code:
    struct personnel
    {
        int number;
        int phone_number;
        int age;
        char occupation[25];
        char surname[25];
        char first_name[10];
        char Address[30];
        char gender;
        DATE dob;
    };
    How exactly do you expect to access Address.house_number when Address isn't a struct?

    Error E2040 Assignment_original.c 265: Declaration terminated incorrectly
    Code:
    /* Case 3 */
    
    /*------------------------------------------------------------------------------------/
      | Function: Edit A Customer                                                                   |
      |                                                                                                           |
      | Purpose: Edit A Customer From The Banking System                            |
      |                                                                                                           |
      | Arguements: A Pointer To The Customer Array                                     |
      |--------------------------------------------------------------------------------------*/
    
    {
    Care to give this anonymous block of code a name and make a proper function out of it?

    Try writing in smaller chunks and testing as you go. It makes it much easier to catch little errors when you know they cropped up in the last 10 lines of code, instead of the last 500. Write, compile, test, write, compile, test, etc. And do more planning before you start typing. Sit down and think through the problem and solution. Then, start to draft your solution, necessary data structures, pseudo code, etc on paper and verify the logic that way first. Then start coding. While it takes longer to get to the point of coding, you will finish your programs faster, get stuck less and end up with fewer bugs.

  3. #3
    Registered User
    Join Date
    Feb 2011
    Posts
    17
    You're beyond me, but is the space after the period supposed to be there?
    Code:
    while ( person_array[i]. number !=0 && i < MAX_PERSONS )

  4. #4
    Banned
    Join Date
    Apr 2011
    Location
    Santry, Ireland
    Posts
    29
    omg thank you so much!! its always stupid lil mistakes that screw these things up!! do u mind if i contact u if i have any more problems?? i need to get 55% to pass my year!!

  5. #5
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    It just might be a good idea to turn on line numbering in your editor/IDE... then look at the lines the compiler is pointing you at... also note that it's telling you what's wrong with each line.

  6. #6
    Banned
    Join Date
    Apr 2011
    Location
    Santry, Ireland
    Posts
    29
    jus turned on the number line :P thnx for the tip haha

  7. #7
    Banned
    Join Date
    Apr 2011
    Location
    Santry, Ireland
    Posts
    29
    okay i jus added the struct address
    Code:
    struct Address
    {
        int house_number;
        char street;
        char city;
    };
    
    typedef struct address ADDRESS;
    and the errors are still there??

  8. #8
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by irishfeeney92 View Post
    okay i jus added the struct address
    Code:
    struct Address
    {
        int house_number;
        char street;
        char city;
    };
    
    typedef struct address ADDRESS;
    and the errors are still there??
    Are the street addresses and city names single characters? If not you need to create char arrays to hold them...
    Code:
    struct Address
    {
        int house_number;
        char street[48];
        char city[24];
    };
    Plus, looking at your code I see you've defined multiple structs each holding only a fraction of the needed information... You would do yourself a huge favor by unifying all that information into a single struct...
    Last edited by CommonTater; 04-27-2011 at 03:45 PM.

  9. #9
    Banned
    Join Date
    Apr 2011
    Location
    Santry, Ireland
    Posts
    29
    hey CommonTator i did what u said and defined the size of the arrays....no luck

  10. #10
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    The new version of your code would be immensely helpful here...

  11. #11
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by irishfeeney92 View Post
    hey CommonTator i did what u said and defined the size of the arrays....no luck
    "No Luck" tells me nothing of use.

    Compilers report errors for a reason... like I said before, go to each of the line numbers in the error reports. The compiler is telling you what is wrong with that line... it's not pulling your leg, it means what it says. Try to fix each error in turn until there are none.

    If you still have problems after that... post your current code and the error messages you're getting.

  12. #12
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Another approach would be this
    A development process

    As a better long term alternative to
    - write several hundred lines of crap
    - find out that it doesn't compile - "shock horror, maybe I'm not the leet coder I thought I was"
    - dump the whole sorry mess on a forum for someone else to fix.
    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.

  13. #13
    Banned
    Join Date
    Apr 2011
    Location
    Santry, Ireland
    Posts
    29
    okay here my new code then......

    Code:
    #include<stdio.h>
    #include<conio.h>
    #define MAX_PERSONS 50
    
    /* Assignment 3A (55 Marks Needed)
        Write a Program To Create A Banking Database */
        
    /* Declaration Of Structures */
    
    
    struct acc_type
    {
    char name[50];
    float balance;
    };
    struct acc_type account[20];
    int number;
    int current;
    
    typedef struct acc_type ACC_TYPE;
    
    
    struct date 
    {
        int day;
        int month;
        int year;
    };
    
    
    typedef struct date DATE;
        
    struct Address
    {
        int house_number;
        char street[25];
        char city[15];
    };
    
    typedef struct address ADDRESS;
    
    
        
    struct personnel
    {
        int number;
        int phone_number;
        int age;
        char occupation[25];
        char surname[25];
        char first_name[10];
        char Address[30];
        char gender;
        DATE dob;
    };
    typedef struct personnel CUSTOMER;
        
    
    /* Function Prototypes */
    
    void add_a_customer(CUSTOMER []);
    void delete_a_customer(CUSTOMER []);
    void edit_a_customer(CUSTOMER []);
    void add_money_to_account(CUSTOMER []);
    void withdraw_money_from_account(CUSTOMER []);
    void display_a_customer(CUSTOMER []);
    void display_customer_details(CUSTOMER *);
    void apply_for_overdraft(CUSTOMER []);
    void init_database(CUSTOMER []);
    int  search_database(CUSTOMER [], int);
    int  menu(void);
    
    /* Main Program Scope */
    
    void main()
    
    {
        CUSTOMER persons[MAX_PERSONS];
        int menu_choice;
        
        init_database(persons);
        
        do
        {
            menu_choice = menu();
            switch ( menu_choice )
            {
                case 1 : add_a_customer(persons);
                         break;
                
                case 2 : delete_a_customer(persons);
                         break;
                
                case 3 : edit_a_customer(persons);
                         break;
                    
                case 4 : add_money_to_account(persons);
                         break;
                
                case 5 : withdraw_money_from_account(persons);
                         break;
                
                case 6 : apply_for_overdraft(persons);
                         break;
                
                case 7 : search_database(persons);
                         break;
                
                case 8 : display_customer_details(persons);
                         break;
            }
            
        }
        while ( menu_choice != 0);
         
        }
        
         /* Menu Display */
    
    
    
            /*------------------------------------------------------------------------------------/     
                    | Function: Display A Menu                                                                     |
                    |                                                                                                            |
                    | Purpose: Display A Menu For The Customer To Make A Choice              |
                    |                                                                                                            |
                    | Arguements: Calls A Function When Choice Is Made                             |
                    |--------------------------------------------------------------------------------------*/
        
        
        int menu(void)
        {
            int choice;
           
            /*Display the menu to the user*/
            printf("1.  Add an account.\n\n");
            printf("2.  Delete an account.\n\n");
            printf("3.  Edit an account.\n\n");
            printf("4.  Add money into an account\n\n");
            printf("5.  Withdraw money from an account\n\n");
            printf("6.  Apply for an overdraft\n\n");
            printf("7.  Search the database\n\n");
            printf("8.  Display customer details\n\n");
            printf("0.  End program.\n\n");
           
            do
            {
                scanf("%d",&choice);
                fflush(stdin);
            } while( choice < 0 || choice > 9 );
           
            return choice;
        }
        
         /* Case 1 */
        
            /*------------------------------------------------------------------------------------/
                    | Function: Add A Customer                                                                    |
                    |                                                                                                            |
                    | Purpose: Add A Customer To The Banking System                                 |
                    |                                                                                                            |
                    | Arguements: A Pointer To The Customer Array                                     |
                    |--------------------------------------------------------------------------------------*/
        
        void add_a_customer(CUSTOMER person_array[]) 
        {
            int i=0;
            
            /*Search The Array For Empty Slot.
                        An Empty Slot = 0                        */
            
            while ( person_array[i]. number !=0 && i < MAX_PERSONS )
                if ( i == MAX_PERSONS)
                    printf(" Unfortunatly The Database Is Full!!\n");
                else                                                   /* Add To Database */
                {
                    printf("\n\n Customer Number (1 To 4 Digits, Except 0) : ");
                    do
                        scanf( "%3d",&person_array[i].number);
                    while (person_array[i].number<=0);
                        
                    
                    /*Customer Details Gender */
                    printf("\n Customer Gender : " );
                    scanf ("%7s",person_array[i].gender);
                    
                        
                    /*Customer Details Name */
                    printf("\n Customer Surname (Maximum 25 Characters) : " );
                    scanf ("%25s",person_array[i].surname);
                    printf("\n First Name (Maximum 10 Characters) : " );
                    scanf ("%25s",person_array[i].first_name);
                    
                    /*Customer Details Date Of Birth */
                    
                    printf("\nDate Of Birth\n" );
                    printf("    Day (1 Or 2 Digits) ; ");
                    scanf ("%2d",&person_array[i].dob.day);
                    printf("    Month (1 Or 2 Digits ; ");
                    scanf ("%2d",&person_array[i].dob.month);
                    printf("    Year (1 Or 2 Digits ; ");
                    scanf ("%2d",&person_array[i].dob.year);
                    
                    /*Customer Details Occupation */
                    
                    printf("\nJob:");
                    scanf("%20s",person_array[i].occupation);
                    
                    /*Customer Details Address */
                    printf("House Number :  ");
                    printf("    House (1 - 3 Digits) ; ");
                    scanf ("%2d",&person_array[i].Address.house_number);
                    printf("Street Name :  ");
                    scanf ("%25s",&person_array[i].Address.street);
                    printf("City :  ");
                    scanf ("%15s",&person_array[i].Address.city);
                        
                    /*Customer Details Phone Number */    
                    printf("Phone Number :  ");
                    printf("Phone (7 Or 10 Digits) ; ");
                    scanf ("%10s",&person_array[i].phone_number);
                    
                }
                
            }
            
        /* Case 2 */
            
            /*------------------------------------------------------------------------------------/
                    | Function: Delete A Customer                                                                |
                    |                                                                                                            |
                    | Purpose:Delete A Customer From The Banking System                           |
                    |                                                                                                            |
                    | Arguements: A Pointer To The Customer Array                                     |
                    |--------------------------------------------------------------------------------------*/
                    
            void delete_a_customer(CUSTOMER person_array[])
            
            {
                int CUSTOMER_number;
                int pos;
                
            /* A Customer Is Deemed Deleted By Placing A 0 In The Customer Number */
                
            /* First The Customer Number Has To Be Obtained */
            printf(" Please Enter Your Personal Number : ");
            do
                            
            scanf("%10d",&CUSTOMER_number);
            while(CUSTOMER_number <= 0 );
               
            pos = search_database(person_array,CUSTOMER_number);
           
            if(pos == MAX_PERSONS)                    /* Yes */          
                printf("This Customer is not in the database\n");
            else                                      /* No */          
            {
                printf("Customer Account number %10d is deleted.\n",CUSTOMER_number);
                person_array[pos].number == 0;
            }
        }
        
        
        /* Case 3 */
        
            /*------------------------------------------------------------------------------------/
                    | Function: Edit A Customer                                                                   |
                    |                                                                                                           |
                    | Purpose: Edit A Customer From The Banking System                            |
                    |                                                                                                           |
                    | Arguements: A Pointer To The Customer Array                                     |
                    |--------------------------------------------------------------------------------------*/
        
            {
                
            int account_number;
            int pos;
        
            printf("Customer Account Number to edit: ");
            do
            scanf("%d",&account_number);
            while(account_number <=0 || account_number > SIZE);
            
            pos = deletion_search(customer, account_number);
            
            if(pos==SIZE)
            printf("This customer is not in the database\n");
            else
            {
                  /* Customer Name */
            printf("\n\nCustomer Surname (Up to 25 letters): ");
            scanf("%25s",customer[pos].surname);
                
            printf("\nFirst Name (Up to 10 letters): ");
            scanf("%10s",customer[pos].first_name);
                
                  /* Customer Date Of Birth */  
            printf("\nDate of Birth\n");
            printf("\nDay (1-31): ");
            scanf("%d",&customer[pos].dob.day);
            printf("\nMonth (1-12): ");
                
            scanf("%2d",&customer[pos].dob.month);
            printf("\nYear (2 digits i.e. 1990 is 90): ");
            scanf("%2d",&customer[pos].dob.year);
                
            printf("\nOverdraft Taken (Yes or No): ");
                
            scanf("%3s",customer[pos].overdraft);
            
               
            printf("\nBalance: ");
            scanf("%d",&customer[pos].balance);
            printf("\n\n");
            
            }
        
        }
    
        /* Case 4 */
    
            /*------------------------------------------------------------------------------------/
                    | Function: Add Money To An Account                                                   |
                    |                                                                                                           |
                    | Purpose: Add Money To A Customers Account                                      |
                    |                                                                                                           |
                    |                                                                                                           |
                    |--------------------------------------------------------------------------------------*/
    
    
    
            void add_money_to_account()
    
            {
                
            float add_sum;
            char dummy;
                
            printf("\nThe current balance for %s is %c%4.2f",account[current].name,156,
            account[current].balance);
                
            printf("\nHow much do you want to add to the account? %c",156);
            dummy=getch(); /* Clear Out Input Buffer */
                
            scanf("%f",&add_sum);
            if(add_sum < 0)
            {
            printf("\nNo negative sums allowed here");
            return;
            }
            account[current].balance += add_sum;
            printf("\nThe new balance is %c%4.2f",156,account[current].balance);
            return;
            }
    
    
            /* Case 5 */
    
            /*------------------------------------------------------------------------------------/
                    | Function: Withdraw Money From An Account                                      |
                    |                                                                                                           |
                    | Purpose: Withdraw Money From A Customers Account                         |
                    |                                                                                                           |
                    |                                                                                                            |
                    |--------------------------------------------------------------------------------------*/
    
                void withdraw_money_from_account()
            
            {
                
            float take_sum;
            char dummy;
                
            printf("\nThe current balance for %s is %c%4.2f",account[current].name,156,
            account[current].balance);
                
            if(account[current].balance == 0)
            {
                
            printf("\nThis account has zero balance - no overdraft facility!");
            return;
                
            }
            
            printf("\nHow much do you want to take from the account? %c",156);
            dummy=getch();//clear out input buffer
            scanf("%f",&take_sum);
            
            if(take_sum < 0)
            {
                
            printf("\nNo negative sums allowed here");
            return;
                
            }
            
            if(take_sum > account[current].balance)
                
            {
                
            printf("\nInsufficient funds!");
            return;
                
            }
            
            account[current].balance -= take_sum;
            printf("\nThe new balance is %c%4.2f",156,account[current].balance);
            
            }
            
                    
                    
    
    
    
    /* Case 7 */
        
            /*------------------------------------------------------------------------------------/     
                    | Function: Search Database                                                                  |
                    |                                                                                                            |
                    | Purpose: Search Database For Customer                                               |
                    |                                                                                                            |
                    |                                                                                                            |
                    |--------------------------------------------------------------------------------------*/
        
            {
                
            int i =0;
    
            while (i<SIZE && customer[i].account_number != account_number)
            i++;
    
            return (i);
            
            }
        
    
            /* Case 8 */
        
            /*------------------------------------------------------------------------------------/
                    | Function: Display A Customer                                                               |
                    |                                                                                                            |
                    | Purpose: Display A Customer From The Banking System                         |
                    |                                                                                                            |
                    | Arguements: A Pointer To The Customer Array                                     |
                    |--------------------------------------------------------------------------------------*/
        
        void display_a_customer( CUSTOMER person_array )
        {
            int CUSTOMER_number;
            int pos;
        
            /* Get The Customer Number */
            printf(" Customer Number To Display ( 1-4 Digits, Except 0) :");
            do
                scanf("%3d",&CUSTOMER_number);
                while( CUSTOMER_number <= 0);
                    
                /* Find The Customer In The Database */
                pos = seacrh_database( person_array,CUSTOMER_number);
                
                /* Does The Customer Exist In The Databse */
                if ( pos == MAX_PERSONS) /* No */
                printf(" The Selected Customer Is Not In The Databse\n" );
                else                     /* Yes - Display The Details */
                    display_customer_details(&person_array[pos]);
            }
            
            /*------------------------------------------------------------------------------------/
                    | Function: Display A Customers Details                                                  |
                    |                                                                                                            |
                    | Purpose: Display A Customers Details From The Banking System            |
                    |                                                                                                            |
                    | Arguements: A Pointer To The Customers Details                                  |
                    |--------------------------------------------------------------------------------------*/
            
            void display_customer_details(CUSTOMER *ptr)
        {
            printf("\n\n");
            printf("Account number : %d\n",ptr->number);
            printf("Surname        : %s\n",ptr->surname);
            printf("Firstname      : %s\n",ptr->first_name);
            printf("Job            : %s\n",ptr->occupation);
            printf("Surname        : %s\n",ptr->surname);
            printf("Telephone      : %d\n",ptr->phone_number);
            printf("Date of Birth  : %2d/%2d/%2d\n",ptr->dob.day, ptr->dob.month, ptr->dob.year);
            
        }

  14. #14
    Banned
    Join Date
    Apr 2011
    Location
    Santry, Ireland
    Posts
    29
    listen slaem, i came on here for a reason, im in 1st year of college and dont really understand it that well yet, i need help with it, isn that what these sites are for? if i understood it i wouldnt be on here, also i need 55% to pass the year if i dont i have to reapeat next yea, so i dont need little ........ heads like yourself comin on here jus pure abusing me!! so if you dont have any helpful information or anything productive to say, ........ OFF!!!

  15. #15
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by irishfeeney92 View Post
    listen slaem, i came on here for a reason, im in 1st year of college and dont really understand it that well yet, i need help with it, isn that what these sites are for? if i understood it i wouldnt be on here, also i need 55% to pass the year if i dont i have to reapeat next yea, so i dont need little ........ heads like yourself comin on here jus pure abusing me!! so if you dont have any helpful information or anything productive to say, ........ OFF!!!
    Ahem... you need to reign that in, my friend.

    These sites --this one in particular-- exists to help people *LEARN* programming. They aren't here to dish out free code or to fix broken code on demand. (although we occasionally do both) Salem's time, like my own, is given voluntarily... nobody pays us to take abuse from anyone.

    And now I'm going to ask Salem to show you one of his other little tricks... and close this thread.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors that I cannot figure out
    By msanak in forum C++ Programming
    Replies: 5
    Last Post: 03-29-2011, 03:35 AM
  2. Assignment Errors
    By Char*Pntr in forum C Programming
    Replies: 3
    Last Post: 09-01-2010, 12:12 AM
  3. Replies: 3
    Last Post: 04-26-2009, 08:54 AM
  4. i need help with errors in my assignment for class
    By azrael13302473 in forum C++ Programming
    Replies: 1
    Last Post: 07-04-2002, 06:02 PM
  5. Few errors I can't figure out
    By burn in forum C++ Programming
    Replies: 8
    Last Post: 05-07-2002, 08:43 PM