C++ Deposit and Withdraw Money From a Bank Using Constructors

C++ Deposit and Withdraw Money From a Bank Using Constructors




 

#include<iostream.h>
#include<process.h>
class bank
{
int acc;
float bal;
public:
bank()
{
bal=0;
acc=0;
}
void deposit();
void withdraw();
};
bank u;
void bank::deposit()
{
int b;
cout<<”\nEnter the Account no. : “;
cin>>acc;
cout<<”\nEnter the Amount to be deposited :”;
cin>>b;
bal=bal+b;
cout<<endl<<”Balance is :”<<bal;
}
void bank::withdraw()
{
int d;
cout<<”\nEnter the Accont no. :”;
cin>>acc;
cout<<”\nEnter the Balance :”;
cin>>bal;
cout<<”\nEnter the money to be Withdrawn :”;
cin>>d;
if(bal<d)
{
cout<<”\nCannot Withdraw :”;
exit(0);
}
else if(bal>d)
{
cout<<”\nMoney has been Withdrawn: “;
cout<<”\nCurrent balance is: “;
float t=bal-d;
cout<<t;
}
}
void main()
{
cout<<”\n1.Deposit the money :”;
cout<<”\n2.Withdraw the money: “;
int ch;
A:
cout<<”\n\nEnter your choice :”;
cin>>ch;
switch(ch)
{
case 1:
u.deposit();
goto A;
break;
case 2:
u.withdraw();
goto A;
break;
default:
cout<<”\nWrong choice : “;
goto A;
}
}

Click here for more C++ Programs

info@C++

C++ (pronounced “cee plus plus”).C++ is a general-purpose,powerful programming language.C++ is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. C++ was Developed by Bjarne Stroustrup starting in 1979.C++ adds OOPS-object oriented features such as classes, and other enhancements to the C programming language.


Rate this post




Further Reading:
http://en.wikipedia.org/wiki/Deposit
http://en.wikipedia.org/wiki/And
http://en.wikipedia.org/wiki/Withdraw
http://en.wikipedia.org/wiki/Money
http://en.wikipedia.org/wiki/From
http://en.wikipedia.org/wiki/Bank
http://en.wikipedia.org/wiki/Using

You read About:C++ Deposit and Withdraw Money From a Bank Using Constructors

Posted by: Prateek on October 6, 2011


Previous Post: « Next Post: »

© 2017 Trendfy. All rights reserved
Blog Managed by Prateek Jaiswal