# Thread: Beginner who is lost - functions

1. ## 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

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
}
{
return balance+deposit
}
float Print_Balance(balance)
{
return balance-cheque+deposit
}
}

2. 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. I think you should have some global vars to have the datas in. I'm sure though.......

4. by datas I mean the deposit balance and Withdrawal

5. By the way,....I just figuered out something.....you don't really have to use pointers.. do you?

I could be wrong though..

Popular pages Recent additions