Browse Source

refactoring getAvailableBalance

remotes/origin/feature/send-money
fdai6618 2 years ago
parent
commit
47586c3d42
  1. BIN
      src/a.exe
  2. 33
      src/sendmoney.c
  3. BIN
      src/sendmoney.exe
  4. 2
      src/sendmoney.h

BIN
src/a.exe

33
src/sendmoney.c

@ -3,10 +3,35 @@ int main()
{ {
SendMoney(); SendMoney();
} }
double getAvailableAccountBalance(double balance)
double getAvailableAccountBalance(int length)
{ {
double availableBalance;
return balance;
FILE *fp;
fp = fopen("CustomerData.txt", "r");
if (fp == 0)
{
printf("Error: customer data file cannot be opened!\n");
return 0;
}
else
{
char line[length];
while (fgets(line, sizeof line, fp) != NULL)
{
if (sscanf(line, "balance=%lf", &availableBalance) == 1)
{
break;
}
}
fclose(fp);
printf("your balance is : %lf\n", availableBalance);
}
return availableBalance;
} }
// hier wird geprüft ob das Kontonummer gultig ist // hier wird geprüft ob das Kontonummer gultig ist
@ -48,7 +73,7 @@ void getReceiverAccountNumber()
else else
{ {
printf("Kontonummer ist Gueltig");
printf("Kontonummer ist Gueltig\n");
} }
} }
@ -65,8 +90,6 @@ void SendMoney()
int receiverAccountNumber; int receiverAccountNumber;
double availableAccountBalance = getAvailableAccountBalance(length); double availableAccountBalance = getAvailableAccountBalance(length);
printf("%lf", availableAccountBalance);
char tryDifferentAmount; char tryDifferentAmount;
if (amountToSend < 0) if (amountToSend < 0)

BIN
src/sendmoney.exe

2
src/sendmoney.h

@ -6,7 +6,7 @@
#include <string.h> #include <string.h>
bool checkAccount(int accountNumber); bool checkAccount(int accountNumber);
double getAvailableAccountBalance(double balance);
double getAvailableAccountBalance(int length);
double getAmount(double amountToSend); double getAmount(double amountToSend);
void getReceiverAccountNumber(); void getReceiverAccountNumber();

Loading…
Cancel
Save