withdraw and deposit money into account CPP Program
Problem Statement :Write a class for Account. Let it store account data (private) and public functions to withdraw and deposit money into that account.
#include<iostream>
using namespace std;
class Account
{
int acc_no;
int balance;
int wdraw;
public:
Account()
{
acc_no = 123;
balance = 0;
wdraw = 0;
}
void deposit(int num)
{
if(num == acc_no)
{
cout<<"\nI am depositing money...";
cout<<"\nEnter the amount you want to deposit : ";
cin>>balance;
}
else
cout<<"\nIncorrect account number.";
}
void display(int num)
{
if(num == acc_no)
{
cout<<"\nThe current balance of your Account is : "<<balance - wdraw;
}
else
cout<<"\nIncorrect account number.";
}
void withdraw(int num)
{
if(num == acc_no)
{
cout<<"\nI am withdrawing money...";
cout<<"\nEnter the amount to withdraw : ";
cin>>wdraw;
cout<<"\n Transaction was successful";
}
else
cout<<"\nIncorrect account number.";
}
};
int main()
{
Account acc;
int num;
cout<<"\nENter the account number : ";
cin>>num;
acc.deposit(num);
acc.display(num);
acc.withdraw(num);
cout<<endl;
return 0;
}
#COFPROG
Sign up here with your email
1 comments:
Write comments.
ReplyConversionConversion EmoticonEmoticon