Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You will code a C program will manage money in a bank account. You will have 3 a

ID: 3682484 • Letter: Y

Question

You will code a C program will manage money in a bank account. You will have 3 accounts namely checking, savings and credit. The user can choose to withdraw or deposit money in these accounts.

You must have at least 6 user defined functions (prototypes declared below)

• You must define a MAXCREDIT of -4500 •

Your starting bank balances should be as follows: Checking: 256.00, Savings: 1024.00, Credit: -2048.00

// Displays the list of options available -- And prompts for the user’s selection and sets the value of the selection void RunBankMenu(int *choice);

//greets the user void Greeting();

//Takes one double argument and one character argument -- displays the current balance of the account ('C' checking, 'S' savings, 'X' credit) void AccountBalance(double account, char letter);

//takes reference to all the bank account values and the menu selection -- Makes the decision of which transaction should be done void TransactionDecision(int num, double *cPtr, double *sPtr, double *xPtr);

//takes a reference to the selected account balance -- gets the added amount from the user and adds it to the account void DepositMoney(double *accountPtr);

//takes a reference to the selected account balance -- gets the withdrawal amount from the user -- checks to see if there is enough money available or enough credit available -- subtracts the money from the account if available void WithdrawMoney(double *accountPtr, char letter);

Additional Requirements:

• Do NOT declare any pointers for this assignment

• Do NOT use global variables

• Do NOT use break statements to stop loops

• Use function prototypes

• Indent your code properly

Explanation / Answer

/**** C code to manage money in a bank account ****/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define MAXCREDIT 4500

void RunBankMenu(int *choice)
{
printf("Choose Account: 1.Checking 2.Savings 3.Credit 4.Quit ");
scanf("%d",choice);
}

void Greeting()
{
printf("Welcome to *************** Bank ");
}

void AccountBalance(double account, char letter)
{
if (letter == 'C')
{
printf("Balance: %lf ",account);
}
if (letter == 'S')
{
printf("Balance: %lf ",account);
}
else if (letter == 'X')
{
printf("Balance: %lf ",account);
}

}

void DepositMoney(double *accountPtr)
{
double add;
printf("Enter amount you would like to add: ");
scanf("%lf",&add);
*accountPtr = *accountPtr + add;
printf("Current amount: %lf ",*accountPtr);
}

void TransactionDecision(int num, double *cPtr, double *sPtr, double *xPtr)
{
if(num == 1)
{
DepositMoney(cPtr);
}
else if(num == 2)
{
DepositMoney(sPtr);
}
else if(num == 3)
{
DepositMoney(xPtr);
}
else if(num == 4)
{
return ;
}
}


void WithdrawMoney(double *accountPtr, char letter)
{
double credit;
if (letter == 'C')
{
printf("Enter amount you want to credit: ");
scanf("%lf",&credit);
while(credit > MAXCREDIT)
{
printf("MAXCREDIT allowed is 4500 ");
printf("Enter amount you want to credit: ");
scanf("%lf",&credit);

}
if(*accountPtr < credit) printf("Not enough fund available ");
else
{
printf("amount credited ");
*accountPtr = *accountPtr - credit;
}
}
if (letter == 'S')
{
printf("Enter amount you want to credit: ");
scanf("%lf",&credit);
while(credit > MAXCREDIT)
{
printf("MAXCREDIT allowed is 4500 ");
printf("Enter amount you want to credit: ");
scanf("%lf",&credit);

}
if(*accountPtr < credit) printf("Not enough fund available ");
else
{
printf("amount credited ");
*accountPtr = *accountPtr - credit;
}
}
else if (letter == 'X')
{
printf("Enter amount you want to credit: ");
scanf("%lf",&credit);
while(credit > MAXCREDIT)
{
printf("MAXCREDIT allowed is 4500 ");
printf("Enter amount you want to credit: ");
scanf("%lf",&credit);

}
if(*accountPtr < credit) printf("Not enough fund available ");
else
{
printf("amount credited ");
*accountPtr = *accountPtr - credit;
}
}
}

int main()
{
  
double Checking = 256.00 , Savings = 1024.00 , Credit= -2048.00;
int num;
Greeting();
  
while(1)
{

RunBankMenu(&num);
  
if(num == 1) AccountBalance(Checking,'C');
else if(num == 2) AccountBalance(Savings,'S');
else if(num == 3) AccountBalance(Credit,'X');
else return 0;

TransactionDecision(num, &Checking, &Savings, &Credit);

if(num == 1) WithdrawMoney(&Checking,'C');
else if(num == 2) WithdrawMoney(&Savings,'S');
else if(num == 3) WithdrawMoney(&Credit,'X');
else return 0;
  
char l;
printf("Do another transaction ? y or n: ");
scanf(" %c",&l);
if(l == 'n') return 0;
  
}
return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote