my program is about making a class Account and I need to create 3 accounts that includes account number,type,owner's name,balance, and interest rate. and make a function for calculating the monthly interest.I wanna know what's wrong with my code because the output I'm getting is not right
#ifndef ACCOUNT_H
#define ACCOUNT_H
class Account {
public:
Account(char* ='\0',char='S',char* ='\0',double=0.0,double=0.05);
~Account();
void setaccounts(char*,char,char*,double,double);
void setBalance(double);
void setInterestRate(double);
double getBalance(void);
double getInterestRate(void);
void monthlyInterest();
void printAccounts();
private:
char AccountNumber[7];
char type;
char owner[30];
double balance;
double interestRate;
};
#endif
#include<iostream>
using std::cout;
using std::endl;
#include<cstring>
#include"Account.h"
Account::Account(char* accountnumber,char typee,char* Owner,double Balance,double Interestrate){
AccountNumber[0]='\0';
type='\0';
owner[0]='\0';
balance=0.0;
interestRate=0.0;
}
Account::~Account(){
}
void Account::setaccounts(char* accountnumber1,char typee1,char* Owner1,double Balance1,double Interestrate1){
int length=strlen(accountnumber1);
length=(length==7?length:'\0');
type=typee1;
switch(typee1)
{
case 1:
if(typee1=='S')
cout<<"Saving accounts"<<endl;
break;
case 2:
if(typee1=='C')
cout<<"Checking accounts"<<endl;
break;
case 3:
if(typee1=='L')
cout<<"Loans accounts"<<endl;
break;
default:
cout<<'S'<<endl;
}
int length2=strlen(Owner1);
length2=(length2<30?length2:'\0');
balance=Balance1;
interestRate=Interestrate1;
}
void Account::setBalance(double bal){
balance=bal>=0?bal:0;
}
double Account::getBalance(){
return balance;
}
void Account::setInterestRate(double inter){
interestRate=(inter>0 && inter<1)?inter:0.05;
}
double Account::getInterestRate(){
return interestRate;
}
void Account::monthlyInterest(){
balance+=(balance*interestRate)/12;
}
void Account::printAccounts(){
cout<<"The account number: "<<AccountNumber<<endl;
cout<<"The account's type: "<<type<<endl;
cout<<"The name of the account's owner"<<owner<<endl;
cout<<"The balance-amount of money in USD currently existing in the account: "<<balance<<endl;
cout<<"The annnual interest rate is :"<<interestRate<<endl;
cout<<"The monthly interest is: "<<balance<<endl;
}
int main()
{
Account Acc, arrays[3],*theseaccounts;
arrays[0].setaccounts("LAM1234",'C',"Sam Smith",5.3,0.6);
arrays[1].setaccounts("JDM2345",'L',"Mark Wayne",4.3,0.2);
arrays[2].setaccounts("HWN9342",'S',"Drake Bell",2.3,0.9);
theseaccounts=&arrays[3];
theseaccounts->printAccounts();
for(int i=0;i<3;i++){
arrays[i].printAccounts();
}
system("pause");
return 0;
}