#include <stdio.h>
#define CHKGACT 15
#define MMKTACT 10
// FUNCTION DECLARATIONS
void GetAcctType(char AType);
void GetNumberofChecks(int CheckNo);
void ErrorMessage1(void);
void ErrorMessage2(void);
void ErrorMessage3(void);
int CheckFees(int CheckNo, int CFees);
void TotalMonthlyFee(void);
int main(void)
{
// LOCAL DECLARATIONS
char AType; //Account Type
float CheckNof; //Number of checks
float CFees; //Calculation of check fees based on CheckNo
float TMFee; //Total Monthly Fee
char Cont; //Continue with processing more accounts
// STATEMENTS
GetAcctType(AType);
if(AType == 'C' || AType == 'M')
{
GetNumberofChecks(&CheckNo);
if(CheckNo < 0)
{
ErrorMessage2();
getchar();
return 0;
}
else
{
CheckFees(CheckNo, CFees);
TotalMonthlyFee(TMFee);
}
}
else
{
printf("Would you like to calculate monthly fees for another account? Please enter 'Y' or 'N': ");
scanf("%c", Cont);
if (Cont == 'Y')
{
GetAcctType(&AType);
}
else
{
printf("Thank you and Goodbye.\n");
getchar();
return 0;
}
}
getchar();
return 0;
} // main
/* ~~~~~~~~~~~~~~~~~~ GetAcctType ~~~~~~~~~~~~~~~~~~~~~~
This function reads a character response from the keyboard.
Pre Parameter Atype is an address
Post Data read into parameter address
*/
void GetAcctType(char AType)
{
printf("Please enter your account type -- 'C' for checking or 'M' for Money Market: ");
scanf("%c", AType);
getchar();
return;
}// GetAcctType
/* ~~~~~~~~~~~~~~~~~~ GetNumberofChecks ~~~~~~~~~~~~~~~~~~~~~~
This function reads a integer response from the keyboard.
Pre Parameter CheckNo is an address
Post Data read into parameter address
*/
void GetNumberofChecks(int* CheckNo)
{
printf("Please enter the number of checks written for the month: ");
scanf("%d", &CheckNo);
return;
}// GetNumberofChecks
/* ~~~~~~~~~~~~~~~~~~ CheckFees ~~~~~~~~~~~~~~~~~~~~~~
This function calculates the check fee amount based on CheckNo.
Pre Parameter CFees is an address
Post Data read into parameter address
*/
int CheckFees(int CheckNo, int* CFees)
{
if(CheckNo < 20)
{
CFees = (CheckNo * .10);
}
else if(CheckNo >= 20 && CheckNo < 39)
{
CFees == (CheckNo * .08);
}
else if(CheckNo >= 40 && CheckNo < 59)
{
CFees == (CheckNo * .06);
}
else if(&CheckNo >= 60)
{
CFees == (CheckNo * .04);
}
return;
}// GetAcctType
/* ~~~~~~~~~~~~~~~~~~ TotalMonthlyFee ~~~~~~~~~~~~~~~~~~~~~~
This function calculates the total monthly fee amout.
Pre Parameter MTFee is an address
Post Returns either (CheckFees + 10) or (Checkfees +15)
*/
void TotalMonthlyFee(void)
{
// LOCAL DECLARATIONS
int sum;
// STATEMENTS
if (AType == 'C')
{
sum = Cfees + CHKGACT;
printf("The total monthly fee for your checking account is: %d\n", sum);
}
else if (AType == 'M')
{
sum = CFees + MMKTACCT
printf("The total monthly fee for your money market account is: %d\n", sum);
}
else
{
ErrorMessage3(void);
}
return;
}// TotalMonthlyFee
/* ~~~~~~~~~~~~~~~~~~ Error Message1 ~~~~~~~~~~~~~~~~~~~~~~
This function displays an error message to the user.
Pre Parameter Msg1 is an address
Post Data read into parameter address
*/
void ErrorMessage1(void)
{
printf("Your response was not valid. Please try again and this time only enter 'C' for Checking account or 'M' for Money Market account types.");
return;
}// ErrorMessage1
/* ~~~~~~~~~~~~~~~~~~ Error Message2 ~~~~~~~~~~~~~~~~~~~~~~
This function displays an error message to the user.
Pre Parameter Msg2 is an address
Post Data read into parameter address
*/
void ErrorMessage2(void)
{
printf("Your response was not valid. Please try again and this time enter a positive integer.");
return;
}// ErrorMessage2
/* ~~~~~~~~~~~~~~~~~~ Error Message3 ~~~~~~~~~~~~~~~~~~~~~~
This function displays an error message to the user.
Pre Parameter Msg3 is an address
Post Data read into parameter address
*/
void ErrorMessage2(void)
{
printf("Could not process your request for monthly fee. Please check your entries.");
return;
}// ErrorMessage2
ASKER
#include <stdio.h>
#include <math.h>
#define CHKGACT 15.00
#define MMKTACT 10.00
// FUNCTION DECLARATIONS
void GetAcctType(char AType);
void GetNumberofChecks(int* CheckNo);
void ErrorMessage1(void);
void ErrorMessage2(void);
void ErrorMessage3(void);
int CheckFees(int* CFees);
void TotalMonthlyFee(int* TMFee);
//GLOBAL DECLARATIONS
char AType; //Account Type
int CheckNo; //Number of checks
int CFees; //Calculation of check fees based on CheckNo
int TMFee; //Total Monthly Fee
char Cont; //Continue with processing more accounts
int main(void)
{
// STATEMENTS
GetAcctType(AType);
if(AType == 'C' || AType == 'M')
{
GetNumberofChecks(&CheckNo);
if(CheckNo < 0)
{
ErrorMessage2();
system(pause);
return 0;
}
else
{
CheckFees(&CFees);
TotalMonthlyFee(&TMFee);
}
}
else
{
printf("Would you like to calculate monthly fees for another account? Please enter 'Y' or 'N': ");
scanf("%c", Cont);
if (Cont == 'Y')
{
GetAcctType(&AType);
}
else
{
printf("Thank you and Goodbye.\n");
system(pause);
return 0;
}
}
system(pause);
return 0;
} // main
/* ~~~~~~~~~~~~~~~~~~ GetAcctType ~~~~~~~~~~~~~~~~~~~~~~
This function reads a character response from the keyboard.
Pre Parameter Atype is an address
Post Data read into parameter address
*/
void GetAcctType(char AType)
{
printf("Please enter your account type -- 'C' for Checking or 'M' for Money Market: ");
scanf("%c", AType);
return;
}// GetAcctType
/* ~~~~~~~~~~~~~~~~~~ GetNumberofChecks ~~~~~~~~~~~~~~~~~~~~~~
This function reads a integer response from the keyboard.
Pre Parameter CheckNo is an address
Post Data read into parameter address
*/
void GetNumberofChecks(int* CheckNo)
{
printf("Please enter the number of checks written for the month: ");
scanf("%i", &CheckNo);
return;
}// GetNumberofChecks
/* ~~~~~~~~~~~~~~~~~~ CheckFees ~~~~~~~~~~~~~~~~~~~~~~
This function calculates the check fee amount based on CheckNo.
Pre Parameter CFees is an address
Post Data read into parameter address
*/
int CheckFees(int* CFees)
{
if(CheckNo < 20)
{
*CFees = (CheckNo * .10);
}
else if(CheckNo >= 20 && CheckNo < 39)
{
*CFees = (CheckNo * .08);
}
else if(CheckNo >= 40 && CheckNo < 59)
{
*CFees = (CheckNo * .06);
}
else if(CheckNo >= 60)
{
*CFees = (CheckNo * .04);
}
return;
}// GetAcctType
/* ~~~~~~~~~~~~~~~~~~ TotalMonthlyFee ~~~~~~~~~~~~~~~~~~~~~~
This function calculates the total monthly fee amout.
Pre Parameter MTFee is an address
Post Returns either (CheckFees + 10) or (Checkfees +15)
*/
void TotalMonthlyFee(int* TMFee);
{
if (AType == 'C')
{
*TMFee = Cfees + CHKGACT;
printf("The total monthly fee for your checking account is: %9.2d\n", *TMFee);
}
else if (AType == 'M')
{
*TMFee = CFees + MMKTACCT;
printf("The total monthly fee for your money market account is: %9.2d\n", *TMFee);
}
else
{
ErrorMessage3();
}
return;
}// TotalMonthlyFee
/* ~~~~~~~~~~~~~~~~~~ Error Message1 ~~~~~~~~~~~~~~~~~~~~~~
This function displays an error message to the user.
Pre Parameter Msg1 is an address
Post Data read into parameter address
*/
void ErrorMessage1(void)
{
printf("Your response was not valid. Please try again and this time only enter 'C' for Checking account or 'M' for Money Market account types.");
return;
}// ErrorMessage1
/* ~~~~~~~~~~~~~~~~~~ Error Message2 ~~~~~~~~~~~~~~~~~~~~~~
This function displays an error message to the user.
Pre Parameter Msg2 is an address
Post Data read into parameter address
*/
void ErrorMessage2(void)
{
printf("Your response was not valid. Please try again and this time enter a positive integer.");
return;
}// ErrorMessage2
/* ~~~~~~~~~~~~~~~~~~ Error Message3 ~~~~~~~~~~~~~~~~~~~~~~
This function displays an error message to the user.
Pre Parameter Msg3 is an address
Post Data read into parameter address
*/
void ErrorMessage2(void)
{
printf("Could not process your request for monthly fee. Please check your entries.");
return;
}// ErrorMessage2
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
#include <stdio.h>
#include <math.h>
// FUNCTION DECLARATIONS
void GetAcctType(char AType);
void GetNumberofChecks(int* CheckNo);
void ErrorMessage1(void);
void ErrorMessage2(void);
void ErrorMessage3(void);
int CheckFees(int* CFees);
void TotalMonthlyFee(int* TMFee);
//GLOBAL DECLARATIONS
int main(void)
{
//LOCAL DECLARATIONS
char AType; //Account Type
int CheckNo; //Number of checks
int CFees; //Calculation of check fees based on CheckNo
int TMFee; //Total Monthly Fee
char Cont; //Continue with processing more accounts
int MCFee = 15;
int MMFee = 10;
// STATEMENTS
GetAcctType(AType);
if(AType == 'C' || AType == 'M')
{
GetNumberofChecks(&CheckNo);
if(CheckNo < 0)
{
ErrorMessage2();
// system("pause");
return 0;
}
else
{
CheckFees(&CFees);
printf("Your Check Fees are: \n", &CFees);
// TotalMonthlyFee(&TMFee);
}
}
else
{
printf("Would you like to calculate monthly fees for another account? Please enter 'Y' or 'N': ");
scanf_s("%c", Cont);
if (Cont == 'Y')
{
GetAcctType(AType);
}
else
{
printf("Thank you and Goodbye.\n");
// system("pause");
return 0;
}
}
// system("pause");
return 0;
} // main
/* ~~~~~~~~~~~~~~~~~~ GetAcctType ~~~~~~~~~~~~~~~~~~~~~~
This function reads a character response from the keyboard.
Pre Parameter Atype is an address
Post Data read into parameter address
*/
void GetAcctType(char AType)
{
printf("Please enter your account type -- 'C' for Checking or 'M' for Money Market: ");
scanf_s("%c", AType);
return;
}// GetAcctType
/* ~~~~~~~~~~~~~~~~~~ GetNumberofChecks ~~~~~~~~~~~~~~~~~~~~~~
This function reads a integer response from the keyboard.
Pre Parameter CheckNo is an address
Post Data read into parameter address
*/
void GetNumberofChecks(int* CheckNo)
{
printf("Please enter the number of checks written for the month: ");
scanf_s("%i", &CheckNo);
return;
}// GetNumberofChecks
/* ~~~~~~~~~~~~~~~~~~ CheckFees ~~~~~~~~~~~~~~~~~~~~~~
This function calculates the check fee amount based on CheckNo.
Pre Parameter CFees is an address
Post Data read into parameter address
*/
int CheckFees(int* CFees)
{
if(CheckNo < 20)
{
*CFees = (CheckNo * .10);
}
else if(CheckNo >= 20 && CheckNo < 39)
{
*CFees = (CheckNo * .08);
}
else if(CheckNo >= 40 && CheckNo < 59)
{
*CFees = (CheckNo * .06);
}
else if(CheckNo >= 60)
{
*CFees = (CheckNo * .04);
}
return;
}// GetAcctType
/* ~~~~~~~~~~~~~~~~~~ TotalMonthlyFee ~~~~~~~~~~~~~~~~~~~~~~
This function calculates the total monthly fee amout.
Pre Parameter MTFee is an address
Post Returns either (CheckFees + 10) or (Checkfees +15)
*/
/*void TotalMonthlyFee(int* TMFee)
{
if (AType == 'C')
{
*TMFee = CFees + MCFee;
printf("The total monthly fee for your checking account is: %9.2d\n", *TMFee);
}
else if (AType == 'M')
{
*TMFee = CFees + MMFee;
printf("The total monthly fee for your money market account is: %9.2d\n", *TMFee);
}
else
{
ErrorMessage3();
}
return;
}// TotalMonthlyFee*/
/* ~~~~~~~~~~~~~~~~~~ Error Message1 ~~~~~~~~~~~~~~~~~~~~~~
This function displays an error message to the user.
Pre Parameter Msg1 is an address
Post Data read into parameter address
*/
void ErrorMessage1(void)
{
printf("Your response was not valid. Please try again and this time only enter 'C' for Checking account or 'M' for Money Market account types.");
return;
}// ErrorMessage1
/* ~~~~~~~~~~~~~~~~~~ Error Message2 ~~~~~~~~~~~~~~~~~~~~~~
This function displays an error message to the user.
Pre Parameter Msg2 is an address
Post Data read into parameter address
*/
void ErrorMessage2(void)
{
printf("Your response was not valid. Please try again and this time enter a positive integer.");
return;
}// ErrorMessage2
/* ~~~~~~~~~~~~~~~~~~ Error Message3 ~~~~~~~~~~~~~~~~~~~~~~
This function displays an error message to the user.
Pre Parameter Msg3 is an address
Post Data read into parameter address
*/
void ErrorMessage3(void)
{
printf("Could not process your request for monthly fee. Please check your entries.");
return;
}// ErrorMessage3
ASKER
ASKER
#include <stdio.h>
#include <math.h>
// FUNCTION DECLARATIONS
void GetAcctType(char AType);
void GetNumberofChecks(float CheckNo);
void ErrorMessage1(void);
void ErrorMessage2(void);
void ErrorMessage3(void);
void CheckFees(float CFees);
void TotalMonthlyFee(int TMFee);
//GLOBAL DECLARATIONS
int main(void)
{
//LOCAL DECLARATIONS
char AType; //Account Type
float CheckNo; //Number of checks
float CFees; //Calculation of check fees based on CheckNo
// int TMFee; //Total Monthly Fee
char Cont; //Continue with processing more accounts
int MCFee = 15;
int MMFee = 10;
// STATEMENTS
GetAcctType(AType);
if(AType == 'C' || AType == 'M')
{
GetNumberofChecks(CheckNo);
if(CheckNo < 0)
{
ErrorMessage2();
// system("pause");
return 0;
}
else
{
CheckFees(CFees);
printf("Your Check Fees are: \n", CFees);
// TotalMonthlyFee(TMFee);
}
}
else
{
printf("Would you like to calculate monthly fees for another account? Please enter 'Y' or 'N': ");
scanf_s("%c", Cont);
if (Cont == 'Y')
{
GetAcctType(AType);
}
else
{
printf("Thank you and Goodbye.\n");
// system("pause");
return 0;
}
}
// system("pause");
return 0;
} // main
/* ~~~~~~~~~~~~~~~~~~ GetAcctType ~~~~~~~~~~~~~~~~~~~~~~
This function reads a character response from the keyboard.
Pre Parameter Atype is an address
Post Data read into parameter address
*/
void GetAcctType(char AType)
{
printf("Please enter your account type -- 'C' for Checking or 'M' for Money Market: ");
scanf_s("%c", AType);
return;
}// GetAcctType
/* ~~~~~~~~~~~~~~~~~~ GetNumberofChecks ~~~~~~~~~~~~~~~~~~~~~~
This function reads a integer response from the keyboard.
Pre Parameter CheckNo is an address
Post Data read into parameter address
*/
void GetNumberofChecks(float CheckNo)
{
printf("Please enter the number of checks written for the month: ");
scanf_s("%i", CheckNo);
return CheckNo;
}// GetNumberofChecks
/* ~~~~~~~~~~~~~~~~~~ CheckFees ~~~~~~~~~~~~~~~~~~~~~~
This function calculates the check fee amount based on CheckNo.
Pre Parameter CFees is an address
Post Data read into parameter address
*/
void CheckFees(float CFees)
{
float CheckNo;
if(CheckNo < 20)
{
CFees = (CheckNo * .10f);
}
else if(CheckNo >= 20 && CheckNo < 39)
{
CFees = (CheckNo * .08f);
}
else if(CheckNo >= 40 && CheckNo < 59)
{
CFees = (CheckNo * .06f);
}
else if(CheckNo >= 60)
{
CFees = (CheckNo * .04f);
}
return;
}// GetAcctType
/* ~~~~~~~~~~~~~~~~~~ TotalMonthlyFee ~~~~~~~~~~~~~~~~~~~~~~
This function calculates the total monthly fee amout.
Pre Parameter MTFee is an address
Post Returns either (CheckFees + 10) or (Checkfees +15)
*/
/*void TotalMonthlyFee(int* TMFee)
{
if (AType == 'C')
{
*TMFee = CFees + MCFee;
printf("The total monthly fee for your checking account is: %9.2d\n", *TMFee);
}
else if (AType == 'M')
{
*TMFee = CFees + MMFee;
printf("The total monthly fee for your money market account is: %9.2d\n", *TMFee);
}
else
{
ErrorMessage3();
}
return;
}// TotalMonthlyFee*/
/* ~~~~~~~~~~~~~~~~~~ Error Message1 ~~~~~~~~~~~~~~~~~~~~~~
This function displays an error message to the user.
Pre Parameter Msg1 is an address
Post Data read into parameter address
*/
void ErrorMessage1(void)
{
printf("Your response was not valid. Please try again and this time only enter 'C' for Checking account or 'M' for Money Market account types.");
return;
}// ErrorMessage1
/* ~~~~~~~~~~~~~~~~~~ Error Message2 ~~~~~~~~~~~~~~~~~~~~~~
This function displays an error message to the user.
Pre Parameter Msg2 is an address
Post Data read into parameter address
*/
void ErrorMessage2(void)
{
printf("Your response was not valid. Please try again and this time enter a positive integer.");
return;
}// ErrorMessage2
/* ~~~~~~~~~~~~~~~~~~ Error Message3 ~~~~~~~~~~~~~~~~~~~~~~
This function displays an error message to the user.
Pre Parameter Msg3 is an address
Post Data read into parameter address
*/
void ErrorMessage3(void)
{
printf("Could not process your request for monthly fee. Please check your entries.");
return;
}// ErrorMessage3
ASKER
ASKER
ASKER
C is a general-purpose, imperative computer programming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations. By design, C provides constructs that map efficiently to typical machine instructions, so it has found lasting use in applications that had formerly been coded in assembly language, including operating systems as well as various application software for computers ranging from supercomputers to embedded systems. It is distinct from C++ (which has its roots in C) and C#, and many later languages have borrowed directly or indirectly from C.
TRUSTED BY
char GetAcctType()
{
char AType;
printf("Please enter your account type -- 'C' for checking or 'M' for Money Market: ");
scanf("%c", AType);
return AType;
}