Problem 5: A bank in your town updates its customers\' account at the end of eac
ID: 3586178 • Letter: P
Question
Problem 5: A bank in your town updates its customers' account at the end of each month. The bank offers two types of accounts: savings and checking. Every customer must maintain a minimum balance. If a customer balance falls below the minimum balance, there is a service charge of $10.00 for savings accounts and $25.00 dollars for checking accounts. If the balance at the end of the month is at least the minimum balance, the account receives interest as follows: 1. 2. savings accounts receive 4% interest. checking accounts with a balance up to $5,000 more than the minimum balance receive 3% interest, otherwise the interest is 5% write a program that reads a customer's account number (int type), account type (char; s for savings, c for checking), minimum balance that the account should maintain, and current balance. The program should then output the account number, account type, current balance, and an appropriate message. Test your program by running it five time using the following data 46728s 1000 2700 87324 c 1500 7689 79873 s 1000 800 89832 c 2000 3000 98322 c 1000 750Explanation / Answer
Please find the attached files for the C++ program.
For the interest computation it is assumed yearly interest. You can modify as applicable.
Additional requirements can be added as applicable.
There are three files, please save files as name Chegg.cpp, Account.h, Account.cpp respectively
File Chegg.cpp:
//============================================================================
// Name : Chegg.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include "Account.h"
using namespace std;
int main() {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
for(int i=0;i<5;i++)
{
int ac_num,min_bal,cur_bal;
char ac_type;
cout<<"Please enter ac no, ac type, minimum balane and current balance"<<endl;
cin>>ac_num>>ac_type>>min_bal>>cur_bal;
Account* ac=new Account(ac_num,ac_type,min_bal,cur_bal);
ac->DisplayMessage();
}
return 0;
}
Account.h:
/*
* Account.h
*
* Created on: 04-Oct-2017
* Author:
*/
#ifndef ACCOUNT_H_
#define ACCOUNT_H_
class Account {
int ac_no;
char ac_typ;
int min_bal;
int computeInterest(char t,int bal);
public:
Account(int no,char t,int min,int cur);
int cur_bal;
void DisplayMessage();
};
#endif /* ACCOUNT_H_ */
Account.cpp:
/*
* Account.cpp
*
* Created on: 04-Oct-2017
* Author:
*/
#include <iostream>
#include "Account.h"
using namespace std;
Account::Account(int no,char t,int min,int cur) {
// TODO Auto-generated constructor stub
ac_no=no;
ac_typ=t;
min_bal=min;
cur_bal=cur;
}
void Account::DisplayMessage(){
cout<<"Account number: "<<ac_no<<" Account type: "<<ac_typ<<" Current balance: "<<cur_bal<<endl;
int intr;
if(cur_bal<min_bal)
{
cout<<"Minimum balance not maintained, Please deposit at least "<<min_bal-cur_bal<<"$ to avoid charges"<<endl;
if(ac_typ=='s')
cout<<"Your balance at the end of the month will be "<<cur_bal-10<<"$"<<endl;
else
cout<<"Your balance at the end of the month will be "<<cur_bal-25<<"$"<<endl;
}
else
{
intr=computeInterest(ac_typ,cur_bal);
cout<<"Your balance at the end of the month will be "<<cur_bal+intr<<"$"<<endl;
}
}
int Account::computeInterest(char t,int bal){
float interest;
if(t=='s')
{
interest=(float)bal*0.04/12.0;
}
else
{
if(bal>5000)
{
interest=(float)bal*0.05/12.0;
}
else
{
interest=(float)bal*0.03/12.0;
}
}
return interest;
}