struggling very hard with this assignment! Can someone please help? Intro to Pro
ID: 3735958 • Letter: S
Question
struggling very hard with this assignment! Can someone please help?
Intro to Programming in C Large Program 2-Bank simulation Assignment purpose: User defined functions, pointer arguments, Menu driven program You will write a program that will simulate the management of money in 3 accounts: checking, savings, and credit General Requirements: A preprocessor directive must be used to define a MAXCREDIT of-4500 . . . DO NOT declare any pointers for this assignment DO NOT use global variables DO NOT use break statements to stop loops . Use function prototypes .Write comments for each function before each prototype and again before each function definition. Be sure to comment your code adequately .Be sure to indent properly. Check the course textbook and lecture code examples to see how it should be done. . Use meaningful variable names. NOTE: To transfer between accounts, you need to make a withdraw followed by a deposit . Your starting bank balances should be as follows: o Checking: 480.45 o Savings: o Credit: 124.62 -2134.78 . You must have at least 6 user defined functions as follows o No modifications may be made to the functions #define-CRT-SECURE-NO-WARNINGS #include stdio.h> #define MAXCREDIT -4500 of options available // Displays the list //pronpts for the user'sselection and sets the value of the selection void RunBankChoices(intchoice) /ereets the user void Greeting); //Takes one double argunent and one character argument //displays the current balance of the account ('C checking, 'S' savings, 'R credit) vaid AccountBalance(double account, char letter) //takes reference to all the bank account money values and the nenu selectian /Makes the decsion of which trnsaction should be done void TransactionDecision(int num, double "cPtr, double SPtr, double rPtr); //takes a reference to the selected account balance //gets the added anount fron the user and adds it to the account void DepositNoney(double accountPtr); //takes a reference to the selected account balance //gets the withdraual anount fron the user //checks to see if there is enough noney available OR enough credit available //subtracts the noney from the account if available void WithdrawMoney (dauble accountPtr, char letter) Sample output: Welcone to the Bank of coOP 2220 It is a pleasure to manage your checking, savings, and credit account:s -You currently have $124.62 in your savings account You currently have $480.45 in your checking account You currently have -2134.7B credit balance (1 to DEPOSIT to CHECKING (21 to NITHDRAN Erom CHECKING (3 to DEPOSIT to SAVINGS 4) to |THORAX from SAVINGS 5) to DEPOSIT to CREDIT (6 to TAKE an ADVANCE from CREDIT (T) for all ACCOUNT BALANCES (-1) QUITExplanation / Answer
program:--
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#define MAXCREDIT -4500
//Displays the list of options available
//prints the user's selection and sets the value of selection
void RunBankChoices(int *choice);
//greets the user
void Greeting();
//takes the one double argument and one character argument
//displays the current balance of the account ('C' checking, 'S' savings, 'R' credit)
void AccountBalance(double account, char letter);
//takes reference to all the bank account money values and the menu selection
//makes the decion of which transaction should be done
void TransactionDecision(int num, double *cPtr, double *sPtr, double *rPtr);
//takes a reference to the selected account balance
//gets the added amount from 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
//substracts the money from the account if available
void WithdrawMoney(double *accountPtr, char letter);
//Displays the list of options available
//prints the user's selection and sets the value of selection
void RunBankChoices(int *choice)
{
int c;
printf(" --------------------------------------------- ");
printf("(1) to DEPOSIT to CHECKING (2) to WITHDRAW from CHECKING (3) to DEPOSIT to SAVINGS (4) to WITHDRAW from SAVINGS (5) to DEPOSIT to CREDIT (6) to TAKE an ADVANCE from CREDIT (7) for all ACCOUNT BALANCES (-1) QUIT");
printf(" Enter your choice: ");
scanf("%d",&c);
*choice=c;
}
//greets the user
void Greeting()
{
printf("*************************************");
printf(" Welcome to the Bank of COP 2220");
printf(" It is a pleasure to manage your checking, savings, and credit accounts");
}
//takes the one double argument and one character argument
//displays the current balance of the account ('C' checking, 'S' savings, 'R' credit)
void AccountBalance(double account, char letter)
{
if (letter=='C')
{
printf(" --You currently have %lf in your checking account",account);
}
else if (letter=='S')
{
printf(" --You currently have %lf in your savings account",account);
}
else
{
printf(" --You currently have %lf in your credit account",account);
}
}
//takes reference to all the bank account money values and the menu selection
//makes the decion of which transaction should be done
void TransactionDecision(int num, double *cPtr, double *sPtr, double *rPtr)
{
if (num==1)
{
DepositMoney(cPtr);
printf(" Money Deposited..!");
}
else if (num==2)
{
WithdrawMoney(cPtr, 'C');
printf(" Money Debited..!");
}
else if (num==3)
{
DepositMoney(sPtr);
printf(" Money Deposited..!");
}
else if (num==4)
{
WithdrawMoney(sPtr, 'S');
printf(" Money Debited..!");
}
else if (num==5)
{
DepositMoney(rPtr);
printf(" Money Deposited..!");
}
else if (num==6)
{
WithdrawMoney(rPtr, 'R');
printf(" Money Debited..!");
}
else if (num==7)
{
AccountBalance(*cPtr, 'C');
AccountBalance(*sPtr, 'S');
AccountBalance(*rPtr, 'R');
}
else
exit(0);
}
//takes a reference to the selected account balance
//gets the added amount from user and adds it to the account
void DepositMoney(double *accountPtr)
{
double money;
printf("Amount to deposit: ");
scanf("%lf",&money);
*accountPtr=*accountPtr+money;
}
//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
//substracts the money from the account if available
void WithdrawMoney(double *accountPtr, char letter)
{
double money;
printf("How much amount do you want: ");
scanf("%lf",&money);
if(letter=='R' && *accountPtr>MAXCREDIT && *accountPtr-money>=MAXCREDIT )
*accountPtr=*accountPtr-money;
else if(*accountPtr>=money && letter!='R')
*accountPtr=*accountPtr-money;
else
printf("You dont have enough balance to withdraw!");
}
//main function
void main()
{
double checkingAcc = 480.45, savingsAcc = 124.62, creditAcc = -2134.78;//initial balances
int choice=0;
Greeting(); //call greeting function
while(choice!=-1) //while choice not equal to -1 repeat loop
{
printf(" ************************************* ");
//calls for balances
AccountBalance(checkingAcc, 'C');
AccountBalance(savingsAcc, 'S');
AccountBalance(creditAcc, 'R');
RunBankChoices(&choice); //call choices
TransactionDecision(choice, &checkingAcc, &savingsAcc, &creditAcc); //call transactions
}
}
output:--
*************************************
Welcome to the Bank of COP 2220
It is a pleasure to manage your checking, savings, and credit accounts
*************************************
--You currently have 480.450000 in your checking account
--You currently have 124.620000 in your savings account
--You currently have -2134.780000 in your credit account
---------------------------------------------
(1) to DEPOSIT to CHECKING
(2) to WITHDRAW from CHECKING
(3) to DEPOSIT to SAVINGS
(4) to WITHDRAW from SAVINGS
(5) to DEPOSIT to CREDIT
(6) to TAKE an ADVANCE from CREDIT
(7) for all ACCOUNT BALANCES
(-1) QUIT
Enter your choice: 1
Amount to deposit: 100
Money Deposited..!
*************************************
--You currently have 580.450000 in your checking account
--You currently have 124.620000 in your savings account
--You currently have -2134.780000 in your credit account
---------------------------------------------
(1) to DEPOSIT to CHECKING
(2) to WITHDRAW from CHECKING
(3) to DEPOSIT to SAVINGS
(4) to WITHDRAW from SAVINGS
(5) to DEPOSIT to CREDIT
(6) to TAKE an ADVANCE from CREDIT
(7) for all ACCOUNT BALANCES
(-1) QUIT
Enter your choice: 2
How much amount do you want: 100
Money Debited..!
*************************************
--You currently have 480.450000 in your checking account
--You currently have 124.620000 in your savings account
--You currently have -2134.780000 in your credit account
---------------------------------------------
(1) to DEPOSIT to CHECKING
(2) to WITHDRAW from CHECKING
(3) to DEPOSIT to SAVINGS
(4) to WITHDRAW from SAVINGS
(5) to DEPOSIT to CREDIT
(6) to TAKE an ADVANCE from CREDIT
(7) for all ACCOUNT BALANCES
(-1) QUIT
Enter your choice: 3
Amount to deposit: 200
Money Deposited..!
*************************************
--You currently have 480.450000 in your checking account
--You currently have 324.620000 in your savings account
--You currently have -2134.780000 in your credit account
---------------------------------------------
(1) to DEPOSIT to CHECKING
(2) to WITHDRAW from CHECKING
(3) to DEPOSIT to SAVINGS
(4) to WITHDRAW from SAVINGS
(5) to DEPOSIT to CREDIT
(6) to TAKE an ADVANCE from CREDIT
(7) for all ACCOUNT BALANCES
(-1) QUIT
Enter your choice: 4
How much amount do you want: 300
Money Debited..!
*************************************
--You currently have 480.450000 in your checking account
--You currently have 24.620000 in your savings account
--You currently have -2134.780000 in your credit account
---------------------------------------------
(1) to DEPOSIT to CHECKING
(2) to WITHDRAW from CHECKING
(3) to DEPOSIT to SAVINGS
(4) to WITHDRAW from SAVINGS
(5) to DEPOSIT to CREDIT
(6) to TAKE an ADVANCE from CREDIT
(7) for all ACCOUNT BALANCES
(-1) QUIT
Enter your choice: 5
Amount to deposit: 100
Money Deposited..!
*************************************
--You currently have 480.450000 in your checking account
--You currently have 24.620000 in your savings account
--You currently have -2034.780000 in your credit account
---------------------------------------------
(1) to DEPOSIT to CHECKING
(2) to WITHDRAW from CHECKING
(3) to DEPOSIT to SAVINGS
(4) to WITHDRAW from SAVINGS
(5) to DEPOSIT to CREDIT
(6) to TAKE an ADVANCE from CREDIT
(7) for all ACCOUNT BALANCES
(-1) QUIT
Enter your choice: 6
How much amount do you want: 1000
Money Debited..!
*************************************
--You currently have 480.450000 in your checking account
--You currently have 24.620000 in your savings account
--You currently have -3034.780000 in your credit account
---------------------------------------------
(1) to DEPOSIT to CHECKING
(2) to WITHDRAW from CHECKING
(3) to DEPOSIT to SAVINGS
(4) to WITHDRAW from SAVINGS
(5) to DEPOSIT to CREDIT
(6) to TAKE an ADVANCE from CREDIT
(7) for all ACCOUNT BALANCES
(-1) QUIT
Enter your choice: 6
How much amount do you want: 1000
Money Debited..!
*************************************
--You currently have 480.450000 in your checking account
--You currently have 24.620000 in your savings account
--You currently have -4034.780000 in your credit account
---------------------------------------------
(1) to DEPOSIT to CHECKING
(2) to WITHDRAW from CHECKING
(3) to DEPOSIT to SAVINGS
(4) to WITHDRAW from SAVINGS
(5) to DEPOSIT to CREDIT
(6) to TAKE an ADVANCE from CREDIT
(7) for all ACCOUNT BALANCES
(-1) QUIT
Enter your choice: 6
How much amount do you want: 1000
You dont have enough balance to withdraw!
Money Debited..!
*************************************
--You currently have 480.450000 in your checking account
--You currently have 24.620000 in your savings account
--You currently have -4034.780000 in your credit account
---------------------------------------------
(1) to DEPOSIT to CHECKING
(2) to WITHDRAW from CHECKING
(3) to DEPOSIT to SAVINGS
(4) to WITHDRAW from SAVINGS
(5) to DEPOSIT to CREDIT
(6) to TAKE an ADVANCE from CREDIT
(7) for all ACCOUNT BALANCES
(-1) QUIT
Enter your choice: -1
Process exited normally.
Press any key to continue . . .
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.