help me write comments on the following program

#include <iostream>
#include <cstring>
using namespace std;

class Account
{
private:
char number[8]; //account number
char type; //account type s r or l
char owner[30]; //name of the owner
double balance; //amount of money in the account
double InterestRate; //interest

public:
Account(); // constructor
void setNumber (char *num); // function takes char and
void setType (char); // takes character and returns void
void setOwner (char []); // takes character array and returns void
void setBalance (double); // takes double and returns void
void setInterestRate (double); // takes double and returns void

char * getNumber(); //
char getType();
char * getOwner();
double getBalance();
double getInterestRate();

double CalculateInterest();
void print();
};

Account :: Account()
{
number[8]='\0';
type='S';
owner[30]='\0'; // set the default values for constructor
balance=0.0;
InterestRate=0.05;
}
void Account:: setNumber(char *num)
{
char a[4], b[5];
bool x=true,y=true;
strncpy(a,num,4);

for(int j=0; j < 5; j++)
b[j]=num[j+3];



for(int i=0; num[i]<3 ; i++)
{
if(!((num[i]<='Z' && num[i]>='A') || (num[i]<='z' && num[i]>='a')))
x=false;
}

for (int i=3; num[i]<7;i++)
{
if(!(num[i]>='0' && num[i]<='9'))
y=false;
}

if(x=true)
strncpy(number,a,3);
else
cout<<"Invalid entry"<<endl;

if(y=true)
{
for(int x=3; x<=7;x++)
{
number[x]=b[x-3];
}

}

else
cout<<"Invalid Entry"<<endl;


}


void Account:: setType(char x)
{
if(x=='S' || x=='C' || x=='L')
type=x;
else
{ cout << "invalid";
type ='S';
}
}
void Account ::setOwner (char ownername[])
{
if (strlen(ownername)>0 && strlen(ownername)<=30)
strcpy(owner,ownername);
else
{ cout<<"Invalid Input";
owner[30]='\0';
}
}

void Account:: setBalance (double y)
{
if(y>0)
balance = y;
else
{
cout<< "Invalid Input";
balance = 0;
}
}

void Account:: setInterestRate (double z)
{
if(z>=0 && z<=1)
InterestRate= z;
else
{
cout<<"Invalid Input";
InterestRate=0.05;
}
}

char * Account:: getNumber ()
{
return number;
}

char Account :: getType()
{
return type;
}

char * Account :: getOwner ()
{
return owner;
}

double Account:: getBalance ()
{
return balance;
}


double Account :: getInterestRate ()
{
return InterestRate;
}

double Account :: CalculateInterest ()
{
return (balance * InterestRate);

}

void Account:: print()
{
cout<<"Number: "<<number<<endl;
cout<<"Type: ";
if (type=='S' || type=='s')
cout<<"Saving";
else if (type=='C' || type=='c')
cout<<"Checking";
else if (type=='L' || type=='l')
cout<<"Loan";
else
cout<<"Invalid account type"<<endl;
cout<<endl;
cout <<"Owner: " << owner<<endl;
cout<<"Balance ="<< balance<<endl;
cout<<"InterestRate: "<< InterestRate<<endl;
cout <<"Interest: "<< CalculateInterest() <<endl;
}

void main()
{
Account Acc[3];
char accountnumber[8] ;
char accounttype;
char ownername[30];
double accountbalance;
double interestrate;

for(int i=0; i<3; i++)
{
cout<< "\nInput the Number of your account: "<<endl;
cin>> accountnumber;

cout<<"Enter the type of the account(S,C or L): "<<endl;
cin>>accounttype;

cout<<"Enter the name of the owner of the account: "<<endl;
cin>>ownername;

cout<<"Enter the balance of the account: "<<endl;
cin>>accountbalance;

cout<<"Enter the interest rate of your account: "<<endl;
cin>>interestrate;

Acc [i].setNumber( accountnumber);
Acc [i].setType (accounttype);
Acc [i].setOwner (ownername);
Acc [i].setBalance (accountbalance);
Acc [i].setInterestRate (interestrate);
Acc [i].print();

cout <<"The created accounts are \n"<<endl;

Acc [i].getNumber();
Acc [i].getType();
Acc [i].getOwner ();
Acc [i].getBalance ();
Acc [i].getInterestRate();
Acc [i].print();

}
}
Sounds like homework.
hahaha no i wrote the program but im not in the mood to write comments
Well, then wait until you are in the mood, and then you write the comments, we are not here to do that for you, sorry.
what is your nationality
Not going to comment your code, and not going to keep reading this thread either, but:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Account
{
private:
char number[8];	//account number
char type;	//account type s r or l
char owner[30];	//name of the owner
double balance;	//amount of money in the account
double InterestRate;	//interest
//...
}

Account :: Account()
{
number[8]='\0';
type='S';
owner[30]='\0';	// set the default values for constructor
balance=0.0;
InterestRate=0.05;
}
Why would we write comments for you? You are best suited to do that and it should be easy. Unless you didn't write the program.
Topic archived. No new replies allowed.