Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

C++ EXample of Account Class, Exams of Computer Science

Account Class- Withdraw, deposit and calculate interest

Typology: Exams

2017/2018

Uploaded on 05/14/2018

himani-maheshwari
himani-maheshwari 🇮🇳

5

(1)

1 document

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Account Class
#include<iostream>
#include<conio.h>
using namespace std;
class account{
public:
double deposit_amount, withdraw_amount,
remaining_amount,p,r,si,Tot_amount;
int t;
void deposit()
{
cout << endl << "Please enter the amount to be deposited:" <<
endl;
cin >> deposit_amount;
cout << endl;
}
void withdraw()
{
cout << endl << "Please enter the amount to be withdrawn:" <<
endl;
cin >> withdraw_amount;
cout << endl;
remaining_amount=deposit_amount-withdraw_amount;
cout << endl << "Remaining amount after withdrawn:" <<
remaining_amount<<endl;
}
void calculate_interest()
{
cout <<" Principle Amount to calculate interest: ";
cin>>p ;
cout<<" Rate of Interest : ";
cin>>r;
cout <<" Number of years : ";
cin>>t;
si= (p *r*t) /100;
Tot_amount = si + p;
cout<<endl<<"Interest : "<<si;
cout<<endl<<"Total Amount : "<<Tot_amount;
pf2

Partial preview of the text

Download C++ EXample of Account Class and more Exams Computer Science in PDF only on Docsity!

Account Class

#include #include<conio.h> using namespace std; class account{ public: double deposit_amount, withdraw_amount, remaining_amount,p,r,si,Tot_amount; int t;

void deposit() { cout << endl << "Please enter the amount to be deposited:" << endl; cin >> deposit_amount; cout << endl; }

void withdraw() { cout << endl << "Please enter the amount to be withdrawn:" << endl; cin >> withdraw_amount; cout << endl; remaining_amount=deposit_amount-withdraw_amount; cout << endl << "Remaining amount after withdrawn:" << remaining_amount<<endl; }

void calculate_interest() { cout <<" Principle Amount to calculate interest: "; cin>>p ; cout<<" Rate of Interest : "; cin>>r; cout <<" Number of years : "; cin>>t; si= (p rt) /100; Tot_amount = si + p; cout<<endl<<"Interest : "<<si; cout<<endl<<"Total Amount : "<<Tot_amount;

int main() { int selection; account obj; do { cout << "Please make a selection:" << endl; cout << "1.) Deposit" << endl; cout << "2.) Withdraw" << endl; cout << "3.) Calculate vInterest" << endl; cout << "4.) Quit" << endl; cin >> selection; if(selection == 1) { obj.deposit(); } if(selection==2) { obj.withdraw(); } if(selection==3) { obj.calculate_interest(); } }while(selection != 4); return 0; }