Greetings,
I hope someone can help me. i have this C++ assignment to do i hav evryting else lock but i am not gettin the constructor part. see question below.
Define a class to represent a bank account. Include the following members.
Data members
a. name of the depositor
b. account number
c. type of account (savings or current)
d. balance amount in the account
Write member functions to:
a) assign initial values depending on the type of account (use constructor). Assume initial balance is $500 in the case of savings, $1000 in the case of current account.
(this part especially is giving me a hard time)
well the rest of the question is asking to write functions to deposit, withdraw and display and i know what to do there basically an it also mentioned to write a main program to achieve the above functionalities.
please help! the code is below
Code:
//Kemar Lee
//Module No. 1
//Assignment # 1
//Solution to Question 1
//Lecturer: Narsi Bathula
#include<iostream.h>
#include<stdio.h>
using namespace std;
//Statement of Class....
class bankacc
{
char name[15], sav_type[2], cur_type[2];
int acco, bal;
public:
bankacc();
bankacc(char[], char[]);
void readdata();
void deposit();
void withdraw();
void display();
};
//Statement of null constructor and constructor
bankacc::bankacc()
{}
bankacc::bankacc(char sav[] = 500, char cur[] = 1000)
{
strcpy(sav_type, sav);
strcpy(cur_type, cur);
}
// Statement of customer information...
void bankacc::readdata()
{
char s[1], c[1];
cout<<" Enter the name of customer:- "<<endl;
cin>>name;
cout<<" Enter account no:- "<<endl;
cin>>acco;
cout<<" Enter opening balance:- "<<endl;
cin>>bal;
if(sav_type == "s")
{
cout<<" Enter savings amount:- "<<endl;
cin>>s;
}
else
{
cout<<" Enter current amount:- "<<endl;
cin>>c;
}
}
// Statement of deposit function...
void bankacc::deposit()
{
int dep;
cout<< "Enter amount you wish to be deposited: "<<endl;
cin<<dep;
bal = bal + dep;
}
//Statement of Withdrawal function...
void bankacc::withdraw()
{
int wd
cout<< "Enter amount you wish to be withdrawn: "<<endl;
cin>>wd;
while( bal < wd )
{
cout<<"Sorry, Insufficient Balance"<<endl;
cin>>wd;
}
bal = bal - wd;
}
// Statement of display Funtion...
void bankacc::display()
{
cout<<"\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%";
cout<<"\n% %";
cout<<"\n% %";
cout<<"\n Name: %"<<name;
cout<<"\n% %";
cout<<"\n Balance: %$"<<bal;
cout<<"\n% %";
cout<<"\n% %";
cout<<"\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%";
}
// statement of Main Function....
int main()
{
bankacc
getchar();
getchar();
}
yea thts all i have now. Thanks in advance.