I have to write a program that calculates and prints a bank’s service fees for a month. This class isnt for my major but its a gen ed class i have to take. I am just focusing on calculations right now and will worry about formatting later. Right now non of what I am trying to do is working.
So there are two types of bank accounts for this project: commercial and personal. Each kind of account must pay $10.00 per month plus fees based on the number of checks written. The bank’s fees vary depending on the type of account. All checks for a month are assigned the same charge based on the total number of checks written during the month. The per-check fees are computed as follows:
Commercial Account:
$0.10 each for less than 20 checks
$0.08 each for 20 through 39 checks
$0.06 each for 40 through 59 checks
$0.04 each for 60 or more checks
Personal Account:
free if the number of checks used is less than 20
$0.07 each for 20 through 50
$0.10 each for 51 or more checks
My program should prompt the user to enter an account number, an account type (type char), and the number
of checks written. An account type of c or C means a commercial account; an account code of p or P means
personal account. Treat any other character as an error. My program should output the account number, type
of account (Commercial or Personal), number of checks written, and the amount due from the user.
The program MUST utilize functions and MUST contain at least one if statement and at least one switch
statement.I have to write a program that calculates and prints a bank’s service fees for a month. This class isnt for my major but its a gen ed class i have to take. I am just focusing on calculations right now and will worry about formatting later. Right now non of what I am trying to do is working.
So there are two types of bank accounts for this project: commercial and personal. Each kind of account must pay $10.00 per month plus fees based on the number of checks written. The bank’s fees vary depending on the type of account. All checks for a month are assigned the same charge based on the total number of checks written during the month. The per-check fees are computed as follows:
Commercial Account:
$0.10 each for less than 20 checks
$0.08 each for 20 through 39 checks
$0.06 each for 40 through 59 checks
$0.04 each for 60 or more checks
Personal Account:
free if the number of checks used is less than 20
$0.07 each for 20 through 50
$0.10 each for 51 or more checks
My program should prompt the user to enter an account number, an account type (type char), and the number
of checks written. An account type of c or C means a commercial account; an account code of p or P means
personal account. Treat any other character as an error. My program should output the account number, type
of account (Commercial or Personal), number of checks written, and the amount due from the user.
The program MUST utilize functions and MUST contain at least one if statement and at least one switch
statement.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
|
/*************************************************/
/* Author: David Havice */
/* Creation Date: */
/* Due Date: */
/* Course: CSC 135 030 */
/* Professor Name: Professor Tranotti */
/* Assignment: */
/* Filename: template.cdd */
/* Purpose: This is a template that */
/* will be used on all */
/* programs. */
/*************************************************/
#include <iostream>
using namespace std;
void instructions();
int acctNumPrompt();
char acctTypePrompt();
int checksPrompt();
double checkTotal(int checks, char acctType);
double results(int checks, int acctNum, char acctType, double checkTotal);
const double com20Checks = .10;
const double com39Checks = .08;
const double com59Checks = .06;
const double com60Checks = .04;
const double per20Checks = 0;
const double per50Checks = .07;
const double per51Checks = .10;
const double serviceCharge = 10;
int main ()
{
double calculatedTotal;
int finalChecks;
int finalAcctNum;
char finalAcctType;
double finalCheckTotal;
instructions();
finalAcctNum = acctNumPrompt();
finalAcctType = acctTypePrompt();
finalCheckTotal = checkTotal(finalChecks, finalAcctType);
finalChecks = checksPrompt();
calculatedTotal = results(finalChecks, finalAcctNum, finalAcctType, finalCheckTotal);
return 0;
}
void instructions()
{
cout << "This program will calculate your bank charges,\n ";
cout << "based on the amount of checks written and the type of account you have.\n";
}
int acctNumPrompt()
{
int acctNum;
cout << "Please enter your account number.";
cin >> acctNum;
return acctNum;
}
char acctTypePrompt()
{
char acctType;
cout << "Please enter your account type\n\n";
cout << "Enter c or C if you want charges for a commercial account\n\n";
cout << "Enter p or P if you want charges for a personal account\n\n";
cin >> acctType;
return acctType;
}
int checksPrompt()
{
int checks;
cout << "Please enter the amount of checks you written for the month.\n";
cin >> checks;
return checks;
}
double checkTotal(int checks, char acctType)
{
int checkTotal;
switch (acctType)
{
case 'c':
case 'C':
{
if (checks < 20)
{
checkTotal = (checks * com20Checks) + serviceCharge;
}
else if (checks < 40 && checks > 19)
{
checkTotal = (checks * com39Checks) + serviceCharge;
}
else if (checks < 60 && checks > 39)
{
checkTotal = (checks * com59Checks) + serviceCharge;
}
else
{
checkTotal = (checks * com60Checks) + serviceCharge;
}
}
break;
case 'p':
case 'P':
{
if (checks < 20)
{
checkTotal = serviceCharge;
}
else if (checks < 51 && checks > 19)
{
checkTotal = (checks * per50Checks) + serviceCharge;
}
else
{
checkTotal = (checks * per51Checks) + serviceCharge;
}
break;
}
default:
{
cout << "Please enter a valid letter.";
}
}
return checkTotal;
}
double results(int checks, int acctNum, char acctType, double checkTotal)
{
cout << checks << acctNum << acctType << checkTotal;
}
|