Hi all,
I'm fairly new to this forum, but I have read the homework policy and I believe that the following question is within the guidelines.
I'm trying to figure out how to store and print the minimum balance for an account. It gets confusing since I'm not allowed to use functions and arrays. This is my code for the banking system thus far:
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
float balance = 2000.00, deposit, withdrawal, credit, debit;
int choice;
printf("Your current balance is $%.2f \n\n", balance);
printf("Transaction options: \n\n");
printf("1 - Deposit funds (credit transaction) \n");
printf("2 - Withdraw funds (debit transaction) \n");
printf("3 - Print statement of account \n");
printf("4 - Compute interest and exit \n\n");
printf("Please indicate your option: \t");
scanf("%d", &choice);
while(choice != 4) {
if(choice==1) {
printf("\nHow much do you want to deposit?\n");
scanf("%f", &deposit);
credit = balance + deposit;
printf("Your current balance is %.2f \n\n", credit);
balance = credit;
}
else if(choice==2) {
printf("\nHow much do you want to withdraw?\n");
scanf("%f", &withdrawal);
debit = balance - withdrawal;
printf("Your current balance is $%.2f \n\n", debit);
balance = debit;
}
else if(choice==3) {
printf("\nCurrent balance: $%.2f\n\n", balance);
}
printf("Transaction options: \n\n");
printf("1 - Deposit funds (credit transaction) \n");
printf("2 - Withdraw funds (debit transaction) \n");
printf("3 - Print statement of account \n");
printf("4 - Compute interest and exit \n\n");
printf("Please indicate your option: \t");
scanf("%d", &choice);
}
system("PAUSE");
}
The value for the minimum balance would be printed under "Current balance: ..." when the user selects choice #3 (Print statement of account). I know that I will need another variable to store the minimum balance, but I'm not completely understanding the logic behind it. Can someone help me with this? I'm not necessarily asking for the code yet; I just want to understand how it is supposed to work. If I'm still lost, I would appreciate it if someone could show me the correct code. Thanks!