Question
Programing in C I was done with the project and it was working perfectly, I added a couple header comment and now I have over
Programing in C
I was done with the project and it was working perfectly, I added a couple header comment and now I have over 50 error and warning. Here is my program.
//precompiler directives
#define _CRT_SECURE_NO_WARNINGS //to avoid scanf warning or error
#include
#include
#define MAXCREDIT -4500
// Function prototypes
void Greeting() //Greeting function
void BankMenu(int *choice); // Menu function
void AccountBalance(double account, char letter); // Account balance function
void TransactionDecision(int num, double *cPtr, double *sPtr, double *xPtr); // Decision function
void DepositMoney(double *balance, double amount); // Deposit function
void WithdrawMoney(double *balance, double amount); // Withdraw function
main(void)
{// Declare variable
double checking = 256.00, savings = 1024.00, credit = -2048.00;
int choice = 0;
Greeting(); // Call Greeting function
// Display accounts balance
printf(" -- You currently have $%.2f in your CHECKING account ", checking);
printf(" -- You currently have $%.2f in your SAVINGS account ", savings);
printf(" -- You currently have $%.2f in your CREDIT account ", credit);
while (choice != 8) // Condition to end the loop
{
BankMenu(choice); // Call the menu function
TransactionDecision(choice, &checking, &savings, &credit); // Call the decision function
}
return (0);
}
// Greeting function
void Greeting()
{
printf("Welcome to the COP 2220 Bank! ");
printf("It is a pleasure to make buisness with you. ");
return;
}
// BankMenu function
void BankMenu(int *choice)
{
printf("Please select one of the following options: "); // Ask to select an option
// Display the menu
printf("---------------------------------------- ");
printf(" (1) to DEPOSITE to CHECKING ");
printf(" (2) to WITHDRAW from CHECKING ");
printf(" (3) to DEPOSITE to SAVINGS ");
printf(" (4) to WITHDRaw from SAVINGS ");
printf(" (5) to DEPOSIT to CREDIT ");
printf(" (6) to TAKE an ADVANTAGE from CREDIT ");
printf(" (7) for all ACCOUNT BALANCES ");
printf(" (8) QUIT ");
printf("---------------------------------------- ");
scanf("%d", choice); // Scan the user decsion
// Condition for invalid selection
if ((*choice < 0) || *choice > 8)
{
printf("-- ERROR! Please try again -- "); // display error message
BankMenu(*choice); // Call menu function
}
return;
}
// Transaction decision function
void TransactionDecision(int num, double *cPtr, double *sPtr, double *xPtr)
{
if (num == 1) // Condition
{
double amount; // Declare variable
printf(" Deposit to CHECKING "); // Display selection
AccountBalance(*cPtr, 'C'); // Call account balance, Display checking balance
printf("Enter the amount to deposit: "); // Ask for amount
scanf("%lf", &amount); // Sacn amount
if (amount > 0) // Condition
{
DepositMoney(cPtr, amount); // Call deposit function
}
// Condition for error
else
{
printf(" -- ERROR -- Please try again. "); // Display error message
}
AccountBalance(*cPtr, 'C'); // call accountBalance function, Display checking balance
}
else if (num == 2) // Condition
{
double amount; // Declare variable
printf(" Withdraw from CHECKING "); // Display selection
AccountBalance(*cPtr, 'C'); // call accountBalance function, Display checking balance
printf("Enter the amount to withdraw: "); // Ask for amount
scanf("%lf", &amount); // Scan the amount
if (amount > 0) // Condition
{
if (*cPtr >= amount) // Condition
{
WithdrawMoney(cPtr, amount); // Call withdraw function
}
else // Error condition
{
// Display error message
printf(" -- ERROR -- insufficient funds! ");
printf("Maximum withdrawal allowed: $%.2f ", *cPtr);
}
}
else
printf("-- ERROR -- Please try again "); // Display error message
AccountBalance(*cPtr, 'C');// call accountBalance function, Display checking balance
}
else if (num == 3) // Condition
{
double amount; // Declare variable
printf(" Deposit to SAVINGS "); // Display selection
AccountBalance(*sPtr, 'S'); // call accountBalance function, Display savings balance
printf("Enter the amount to deposit: "); // Ask for amount
scanf("%lf", &amount); // Scan the amount
if (amount > 0) // Condition
{
DepositMoney(sPtr, amount); // Call deposite function
}
else // Error condition
printf("-- ERROR -- Please try again "); // Display error message
AccountBalance(*sPtr, 'S'); // call accountBalance function, Display savings balance
}
else if (num == 4) // Condition
{
double amount; // Declare variable
printf(" Withdraw from SAVINGS "); // Display selection
AccountBalance(*sPtr, 'S'); // call accountBalance function, Display savings balance
printf("Enter the amount to withdraw: "); // Ask for amount
scanf("%lf", &amount); // Scan the amount
if (amount > 0) // Condition
{
if (*sPtr >= amount) // Condition
{
WithdrawMoney(sPtr, amount); // Call withdraw function
}
else
{
// Display error message
printf(" -- ERROR -- insufficient funds! ");
printf("Maximum withdrawal allowed: $%.2f ", *sPtr);
}
}
else // Error condition
printf("-- ERROR -- Please try again "); // Display error message
AccountBalance(*sPtr, 'S'); // call accountBalance function, Display savings balance
}
else if (num == 5) // condition
{
double amount; // Declare variable
printf(" Deposit to CREDIT "); // Display selection
AccountBalance(*xPtr, 'X'); // call accountBalance function, Display credit balance
printf("Enter the amount to deposit: "); // Ask for amount
scanf("%lf", &amount); // Scan for amount
if (amount > 0) // Condition
{
DepositMoney(xPtr, amount); // Call deposit function
}
else // Error condition
printf("-- ERROR -- Please try again "); // Display error message
AccountBalance(*xPtr, 'X'); // call accountBalance function, Display credit balance
}
else if (num == 6) // Condition
{
double amount; // Declare variable
printf(" Withdraw from CREDIT "); // Dislpay selection
AccountBalance(*xPtr, 'X'); // call accountBalance function, Display credit balance
printf("Enter the amount to withdraw: "); // Ask for amount
scanf("%lf", &amount); // Scan the amount
if (amount > 0) // condition
{
if (*xPtr >= MAXCREDIT && amount <= -(MAXCREDIT - *xPtr)) // condition
{
WithdrawMoney(xPtr, amount); // Call withdraw function
}
else // Error condition
{
// Display error message
printf(" -- ERROR -- insufficient Credit available! ");
printf("Maximum withdrawal allowed: $%.2f ", MAXCREDIT);
}
}
else // Error condition
printf("-- ERROR -- Please try again "); // Display error message
AccountBalance(*xPtr, 'X'); // call accountBalance function, Display credit balance
}
else if (num == 7) // Condition
{
printf(" Accounts balance: "); // Display selection
AccountBalance(*cPtr, 'C'); // call accountBalance function, Display checking balance
AccountBalance(*sPtr, 'S'); // call accountBalance function, Display savings balance
AccountBalance(*xPtr, 'X'); // call accountBalance function, Display credit balance
}
else if (num == 8) // Condition
{
printf(" Thank you for choosing the COP 2220 Bank "); // Display message
}
}
// AccountBalance function
void AccountBalance(double account, char letter)
{
char type[100] = ""; // declare variable
switch (letter)
{
case 'C': // Condition
{
strcpy(type, "CHECKING"); // Checking balance
}
break;
case 'S': // Condition
{
strcpy(type, "SAVINGS"); // Savings balance
}
break;
case 'X': // Condition
{
printf(" -- You currently have $%.2f credit balance ", account); // Display credit balance
}
return;
default:
break;
}
// Display selected balance
printf(" -- You currently have $%.2f in your %s account ", account, type);
}
//Function to deposit money
void DepositMoney(double *balance, double amount)
{
*balance += amount; // Deposit money into account
}
//Function to withdraw money
void WithdrawMoney(double *balance, double amount)
{
*balance -= amount; // Withdraw money from account
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started