Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

implement interest from deposit date till withdrawal date #include / / Included the header file for standard input and output #include / / Included the

implement interest from deposit date till withdrawal date
#include // Included the header file for standard input and output
#include // Included the header file for string Operations
#include // Included the header file for vector class
#include // iomanip is a library that is used to manipulate the output of C++ program
class Date {
public:
int year, month, day;
Date(int y, int m, int d) : year(y), month(m), day(d){}
std::string to_string() const {
return std::to_string(year)+"-"+ std::to_string(month)+"-"+ std::to_string(day);
}
};
class Transaction {
std::string transaction_type;
float amount;
float balance;
Date date;
public:
Transaction(std::string type, float a, float b, Date d)
: transaction_type(type), amount(a), balance(b), date(d){}
std::string to_string() const {
return transaction_type +""+ date.to_string()+" Amount: $"+ std::to_string(amount)+" Balance: $"+ std::to_string(balance);
}
};
class Customer {
public:
std::string name;
std::string address;
int age;
std::string telephone_number;
int customer_number;
virtual double get_annual_interest_rate() const {
return 0.0;
}
Customer(const std::string& name, const std::string& address, int age, const std::string& phoneNumber, int id)
: name(name), address(address), age(age), telephone_number(phoneNumber), customer_number(id){}
// Accessors and Modifiers of Data Fields
std::string get_name() const { return name; }
std::string get_address() const { return address; }
int get_age() const { return age; }
std::string get_telephone_number() const { return telephone_number; }
int get_customer_number() const { return customer_number; }
void set_name(const std::string& new_name){ name = new_name; }
void set_address(const std::string& new_address){ address = new_address; }
void set_age(int new_age){ age = new_age; }
void set_telephone_number(const std::string& new_telephone_number){ telephone_number = new_telephone_number; }
void set_customer_number(int new_customer_number){ customer_number = new_customer_number; }
virtual void dummy_function() const {}
};
class Senior : public Customer {
public:
static const double SAVINGS_INTEREST;
static const double CHECKING_INTEREST;
static const double CHECK_CHARGE;
static const double OVERDRAFT_PENALTY;
Senior(std::string name, std::string address, int age, std::string phone, int custNum)
: Customer(name, address, age, phone, custNum){}// Constructor and other member functions...
};
const double Senior::SAVINGS_INTEREST =0.04; // annual rate
const double Senior::CHECKING_INTEREST =0.01; // annual rate. Yes! this is interest rate for the checking account.
const double Senior::CHECK_CHARGE =0.01; //cents for withdrawal
const double Senior::OVERDRAFT_PENALTY =25.0; //dollar
class Adult : public Customer {
public:
static const double SAVINGS_INTEREST;
static const double CHECKING_INTEREST;
static const double CHECK_CHARGE;
static const double OVERDRAFT_PENALTY;
Adult(std::string name, std::string address, int age, std::string phone, int custNum)
: Customer(name, address, age, phone, custNum){}
};
const double Adult::SAVINGS_INTEREST =0.03; // annual rate
const double Adult::CHECKING_INTEREST =0.01; // annual rate. Yes! this is interest rate for the checking account.
const double Adult::CHECK_CHARGE =0.03; //cents for withdrawal
const double Adult::OVERDRAFT_PENALTY =25.0; //dollar
class Student : public Customer {
public:
static const double SAVINGS_INTEREST;
static const double CHECK_CHARGE;
static const double OVERDRAFT_PENALTY;
static const double CHECKING_INTEREST;
Student(std::stringf name, std::string address, int age, std::string phone, int custNum)
: Customer(name, address, age, phone, custNum){}
};
const double Student::SAVINGS_INTEREST =0.04; // annual rate
const double Student::CHECKING_INTEREST =0.01; // annual rate. Yes! this is interest rate for the checking account.
const double Student::CHECK_CHARGE =0.02; //cents for withdrawal
const double Student::OVERDRAFT_PENALTY =25.0; //dollar
class Account {
public:
Customer* customer;
float balance;
int account_number;
std::vector transaction;
void add_interest();
Account(Customer* c, double balance, int num)
: customer(c), balance(balance), account_number(num){}
int get_account_number() const {
return account_number;
}
double get_balance() const {
return balance;
}
// Member functions definitions
virtual void deposit(double amount, Date date)=0;
virtual void withdraw(double amount, Date date)=0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago