I finally think that I've finished, here is the completed code that i will hand in on thursday, if anyone can find any obvious bugs (i.e maths being wrong, spelling mistakes) then please tell me so i can fix them.
I just wanna thank you guys, i doubt that i could have completed this without you lot, i hope that my spelling will pick up the more i code
Anyway on with the code:
Code:
#include <stdio.h>
#include<time.h>
float deposited (float, float*);
float withdrawn (float, float*);
int main()
{
int menu_choice = 0;
int transactions = 0;
float balance = 0;
int nodeposits = 0;
int nowithdraws = 0;
float totaldeposited = 0;
float totalwithdrawn = 0;
time_t timer;
while (menu_choice != 4)
{
printf ("Your current balance = %.2f \n", balance);
printf ("1. Deposit funds \n");
printf ("2. Withdraw funds \n");
printf ("3. Show balance \n");
printf ("4. Quit Program \n");
printf ("Please select what you wish to do (1-4): \n");
scanf ("%d", &menu_choice);
timer = time (NULL);
switch (menu_choice)
{
case 1:
printf ("1. Deposit funds \n");
balance = deposited (balance, &totaldeposited);
nodeposits ++;
transactions ++;
printf("Deposit completed %s \n", asctime(localtime (&timer)));
break;
case 2:
printf ("2. Withdraw funds \n");
balance = withdrawn (balance, &totalwithdrawn);
transactions ++;
nowithdraws ++;
printf("Withdraw completed %s \n", asctime(localtime (&timer)));
break;
case 3:
printf ("3. Show balance \n");
printf ("Your current balance at %s is %.2f \n", asctime(localtime (&timer)), balance);
break;
case 4:
printf ("Exiting... \n");
printf ("closing balance.............%.2f \n", balance);
printf ("completed transactions......%2d \n", transactions);
printf (" \n");
printf ("completed deposits..........%2d \n", nodeposits);
printf ("total of money deposited....%.2f \n", totaldeposited);
printf (" \n");
printf ("completed withdraws.........%2d \n", nowithdraws);
printf ("total of money withdrawn...%.2f \n", totalwithdrawn);
break;
default:
printf("Please Enter a Choice from 1-4\n" );
break;
}
}
return 0;
}
float deposited (float balance, float *ptr_totaldeposited)
{
float deposit = 0;
printf ("Please enter how much you wish to deposit \n");
scanf ("%f", &deposit);
if ((deposit + balance < 999999) || (deposit + balance > 0))
{
balance = balance + deposit;
(*ptr_totaldeposited) = (*ptr_totaldeposited) + deposit;
printf ("Thank you %.2f has been entered into your account\n", deposit);
}
else
printf ("I'm sorry but the number you have entered out of range \n");
return (balance);
}
float withdrawn (float balance, float *ptr_totalwithdrawn)
{
float cashwithdraw = 0, chequewithdraw = 0;
int transtype;
printf ("Please enter how you wish to withdraw \n");
printf ("1. Cash \n");
printf ("2. Cheque\n");
scanf ("%d", &transtype);
switch (transtype)
{
case 1:
{
printf ("How much would you like to withdraw? \n");
scanf ("%f", &cashwithdraw);
balance = balance - cashwithdraw;
(*ptr_totalwithdrawn) = (*ptr_totalwithdrawn) + cashwithdraw;
printf ("%.2f has being withdrawn from your account \n", cashwithdraw);
break;
}
case 2:
{
printf ("How much would you like to withdraw? (maximum of 500) \n");
scanf ("%f", &chequewithdraw);
if ((chequewithdraw > 500) || (chequewithdraw < 0))
printf ("You are limited to a maximum of 500 \n");
{
printf ("%.2f has being withdrawn from your account \n", chequewithdraw);
balance = balance - chequewithdraw;
(*ptr_totalwithdrawn) = (*ptr_totalwithdrawn) + cashwithdraw;
}
break;
default:
printf("Please Enter a Choice from either 1 or 2\n" );
break;
}
}
return (balance);
}