Beginner who is lost - functions

This is a discussion on Beginner who is lost - functions within the C Programming forums, part of the General Programming Boards category; I am having a problem with this - can any one help? Description: This program will balance the users bank ...

  1. #1
    Unregistered
    Guest

    Beginner who is lost - functions

    I am having a problem with this - can any one help?

    Description: This program will balance the users bank account (from an
    intial opening balance of 0) utilizing cheques and deposits
    as the financial transactions. The program will also print
    a balance for the user when Print is selected from the
    menu.

    Data Dictionary:
    Cheque: this is a function that will subtract the amount
    of the cheque from the users bank balance provided
    that there is sufficient funds in the account. If
    there are not suficient funds, the function will
    prompt the user with a message indicating this.

    Deposit: this is a function that will add the amount
    deposited to the users bank account.

    Print: this is a function that will display the users
    current bank balance when requested.

    */

    #include <stdio.h>
    #include <ctype.h>

    /* Function declarations*/

    float Cheque(float*cheque, float *balance);
    float Deposit(float*deposit, float *balance);
    float Print(float balance);

    main()
    {
    float balance = 0.0, cheque, deposit;
    char selection;

    do{
    /* Display a menu for the user. */
    printf("Enter C or c for cheque\n");
    printf("Enter D or d for a deposit\n");
    printf("Enter P or p to print account balance\n");
    printf("Enter Q or q to quit\n");
    printf("Enter Selection:");
    fflush(stdin);
    scanf("%c", &selection);
    /* Convert selection to uppercase. */
    selection=toupper(selection);

    /* Execute the appropriate function. */

    switch(selection)
    {
    case 'C': printf("Enter the amount of the cheque =>");
    scanf("%f",*&cheque);
    if (balance >= cheque)
    Cheque(cheque)
    else
    printf("You do not have sufficient funds for this transaction.");
    break;
    case 'D': printf("Enter the amount of the deposit =>");
    scanf("%f", *&deposit);
    if (*deposit >= 2000.00)
    *deposit = *deposit * 1.01;
    Deposit(*deposit);
    else
    Deposit(*deposit);
    break;
    case 'P': Balance(balance);
    break;
    default: printf("Error - illegal input\n");
    }
    }while(toupper(selection)!='Q');
    }
    /* Function defintion section */

    float Withdrawal_Cheque(*cheque)
    {
    if balance <=0
    return balance - cheque
    }
    float Add_Deposit(*deposit)
    {
    return balance+deposit
    }
    float Print_Balance(balance)
    {
    return balance-cheque+deposit
    }
    }

  2. #2
    Nit
    Nit is offline
    Registered User
    Join Date
    Mar 2002
    Posts
    42
    Could you do two things for us before we begin.

    1. Use code tags ([.code] and closing [./code]) without the periods.

    2. State your problem exactly.

  3. #3
    Registered User Commander's Avatar
    Join Date
    Sep 2001
    Posts
    804
    I think you should have some global vars to have the datas in. I'm sure though.......
    oh i'm sorry! i didn;t realize my fist was rushing to meet ur face!

    MSN :: commander_android@hotmail.com []*[]

  4. #4
    Registered User Commander's Avatar
    Join Date
    Sep 2001
    Posts
    804
    by datas I mean the deposit balance and Withdrawal
    oh i'm sorry! i didn;t realize my fist was rushing to meet ur face!

    MSN :: commander_android@hotmail.com []*[]

  5. #5
    Registered User Commander's Avatar
    Join Date
    Sep 2001
    Posts
    804
    By the way,....I just figuered out something.....you don't really have to use pointers.. do you?

    I could be wrong though..
    oh i'm sorry! i didn;t realize my fist was rushing to meet ur face!

    MSN :: commander_android@hotmail.com []*[]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 12-13-2008, 08:32 AM
  2. Replies: 7
    Last Post: 11-17-2008, 12:00 PM
  3. Totally lost beginner
    By burrissa in forum C Programming
    Replies: 7
    Last Post: 03-29-2004, 07:00 PM
  4. API "Clean Up" Functions & delete Pointers :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-10-2002, 06:53 PM
  5. Variables do not equal functions!!!
    By me@burk. in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 05:24 AM

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