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
|
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
// Constants
const double package_a = 9.95;
const double package_b = 14.95;
const double package_c = 19.95;
void inputData(string&, double&, char&, int&) ;
double feeamount (char,int) ;
void displayOutput(string,double,char,int,double,double);
int main ()
{
// Local Declarations
string name;
int num_checks;
char package;
double intial_balance, new_balance, cost_package, fee_total= 0.0;
//Program statements
inputData(name,intial_balance, package, num_checks);
package = toupper (package) ;
if (package == 'A') // a=9.95
cost_package = package_a;
else if (package=='B') // b=14.95
cost_package = package_b;
else if (package == 'C') // c=19.95
cost_package = package_c ;
else
{
cout<< "\nPlease enter a valid package A, B, or C" <<endl;
return 0;
}
fee_total = feeamount(package,num_checks);
new_balance= intial_balance - fee_total;
// OUTPUT
displayOutput(name,intial_balance,package, num_checks,cost_package,new_balance) ;
return 0;
}
void inputData(string& name, double& initial_balance, char& package, int& num_checks)
{
cout<< "\nEnter name: ";
getline(cin, name);
cout<< "\nEnter initial balance: ";
cin>>initial_balance;
cout<< "\nEnter type of package: ";
cin>>package;
cout<< "\nEnter number of checks: ";
cin>>num_checks;
return;
}
double feeAmount (char package, int num_checks)
{
double cost_package, fee_total;
double fee_checks=0;
if (package=='A')
{
cost_package = package_a;
if (num_checks>10)
{
fee_checks= (num_checks -10)*0.2;
}
else
{ fee_total = cost_package + fee_checks;
}
}
else if (package=='B')
{
cost_package = package_b;
if (num_checks>20)
{
fee_checks=(num_checks - 20)*0.1;
}
else
{
fee_total = cost_package + fee_checks;
}
}
else
{
cost_package = package_c;
fee_total= cost_package;
}
return fee_total;
}
void displayOutput(string name, double initial_balance, char package, int num_checks,double cost_package, double new_balance)
{
// Statements
cout<<setiosflags(ios::fixed) <<setiosflags(ios::showpoint)
<<setprecision(2);
cout<<"t\t_____________________________________________\n"
<<" \n"
<<"\t\t Seigel Passaic Bank \n"<<endl<<endl;
cout<<"t\t\Account summary"<<endl;
cout<<"t\t\------------------------"<<endl<<endl;
cout<<"t\t\Name : "<<setw(45)<<name << endl;
cout<<"t\t\Inital Balance: "<<setw(21)<<"$"<<initial_balance << endl;
cout<<"t\t\package: "<<setw(35)<<"Package"<<package<< endl;
cout<<"t\t\checks : "<<setw<<num_checks<< endl;
cout<<"t\t\fee package: "<<setw(25)<<"$"<<cost_package<< endl;
cout<<"t\t\<<new balance: "<<setw(25)<<"$"<<new_balance << endl<<endl;
if (new_balance<200)
cout<<setw(10)<<right<<"\n"<<"\t\tWarning: Balance too low "<< endl;
cout<<"t\t\_________________________________________\n" <<endl<<endl;
return;
}
|