I have this homework in which I have been working on it: but I dont know what im doing wrong :(
Could anyone help me:
#include <iostream>
#include <cstring>
using namespace std;
class Account
{ private:
char number[8];
char type;
char owner[31];
double balance;
double interestRate;
public:
Account()
{
number[0] = '\0';
type = 'S';
owner[0] = '\0';
balance = 0;
interestRate = 0.05;
}//default numbers
char getnumber();
char gettype();
char getowner();
double getbalance();
double getinterestRate();
//get functions are usless with the print function
void setnumber(char[]);
void settype(char);
void setowner(char[]);
void setbalance(double);
void setinterestRate(double);
void interestpermonth();
void print();
};
void Account::settype(char t)
{
(t=='S' || t=='C' || t=='L')?type = t: 'S';
}//assign type if it is C, S or L
void Account::setowner(char o[])
{ int len;
len = strlen (o); //length of the owner name
if (len < 31)
{strncpy(owner,o,len);//copy the owner name
owner[len]='\0';}
}
void Account::setbalance(double b)
{ if (b>= 0)
balance=b;
}//set balance to the user description if it is positive
void Account::setinterestRate(double ir)
{ if(ir >=0 && ir<=1)
interestRate=ir;
}//set interest rate between 0 and 1
void Account::interestpermonth()
{
balance= balance + (interestRate*balance/12);
}//formula to calculate the interest and add it to the balance
void Account::print()//function to print all the acount informations
{
cout<<"number: "<<number<<endl;
cout<<"type: "<<type<<endl;
cout<<"owner: "<<owner<<endl;
cout<<"balance before interest: "<<balance<<endl;
interestpermonth();
cout<<"balance after interest: "<<balance<<endl;
cout<<"interestRate: "<<interestRate<<endl;
}
int main()
{
Account a[3];//array that contains the 3 acounts
a[0].setnumber("SAAA989");//seting the acount informations
a[0].settype('L');
a[0].setowner("elie malkkoun");
a[0].setbalance(9987);
a[0].setinterestRate(0.07);
a[0].print();
}
The error that i get is:
In function 'int main()':
Line 87: warning: deprecated conversion from string constant to 'char*''
Line 89: warning: deprecated conversion from string constant to 'char*''