Answer to Question #326425 in C++ for viki

Question #326425

Design a class Account that has the following member: Data Fields: account_id(int type), balance(double type)). Member Functions-> withdraw(),deposit(),getmonthly_interest() and parameterize constructor to initialize data members. Use this class to print the balance. Use the withdraw () to withdraw money less than Rs 5000 and then deposit more than or equal 1500 using deposit function. 


1
Expert's answer
2022-04-10T03:12:31-0400
#include<iostream>
#include<vector>


using namespace std;




class Account
{
	int acc_ID;
	double balance;
public:
	Account(int _acc_ID, double _balance)
	:acc_ID(_acc_ID), balance(_balance){}
	void Print()
	{
		cout << "\nBalance is " << balance;
	}
	void withdraw()
	{
		double w;
		cout << "\nPlease enter a money to withdraw:";
		cin >> w;
		if (w < balance&&w<5000)
		{
			balance -= w;
		}
		else
		{
			cout << "\nError!Prohibited operation!";
		}
	}
	void deposit()
	{
		double d;
		cout << "\nPlease enter a money to deposit:";
		cin >> d;
		if (d < 1500)
		{
			cout << "\nToo little amount of deposit!";
		}
		else
		{
			balance += d;
		}
	}
	void getmonthly_interest()
	{
		float annual;
		cout << "\nPlease, enter an annual interest of your deposit:";
		cin >> annual;
		cout<<"\nMonthly interest is "<< annual*balance / 12;
	}
};


int main()
{
	Account a(1, 2500);
	a.deposit();
	a.Print();
	a.withdraw();
	a.Print();
	a.getmonthly_interest();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS