#include<iostream>
#include<string>
usingnamespace std;
class advisor
{
private:
int id;
char name[41];
char rank;
char password[9];
int nbrAdvisees;
public:
advisor()
{
id=0;
strcpy(name,"");
rank='A';
strcpy(password,"");
nbrAdvisees=15;
};
void setId()
{
do{
cin>>id;}while(id>9000||id<1000);
};
void setName()
{
cin.getline(name,40);
};
void setPass(char Rank)
{
rank=Rank;
};
void setPassword()
{
int x=strlen(password);
if(x<8||x>8)
do{
cout<<"The password should be equal to 8 characters.Re-enter it:\n";
cin.getline(password,8);
x=strlen(password);
}while(x<8||x>8);
int p1=0,p2=0;
do{
for(int i=0;i<8;i++)
{
if(password[i]>='A'&&password[i]<='Z'||password[i]>='a'&&password[i]<='z')
p1=1;
if(password[i]>='0'&&password[i]<='9')
p2=2;
}}while(p1!=1||p2!=2);
};
void setNbrAdvisees(int nbr)
{
nbrAdvisees=nbr;
};
float getId()
{
return id;
};
string getName()
{
return name;
};
char getRank()
{
return rank;
if(rank=='A'||rank=='a')
cout<<"Advisor";
if(rank=='C'||rank=='c')
cout<<"Chairperson";
if(rank=='D'||rank=='d')
cout<<"Dean";
};
string getPass()
{
return password;
}
int getNbrAdvisees()
{
return nbrAdvisees;
}
int incrementNbrAdv(int incrnbr)
{
if(nbrAdvisees<50)
nbrAdvisees+=incrnbr;
if(nbrAdvisees>50)
{
nbrAdvisees-=incrnbr;
// if NBR=nbr+cout
}
};
void print()
{
cout<<"The id you entered is: "<<getId()<<endl
<<"The name you entered is: "<<getName()<<endl
<<"Rank: "<<getRank()<<endl
<<"Password: "<<getPass()<<endl
<<"Number of advisees: "<<getNbrAdvisees()<<endl;
int m=strlen(name);
char namecopyed[40-m];
for(int n=0;n<m;n++)
&name[n];
int u=0;
&name[u]=&name[n];//this is the error i dunno why:(
for(u=0;u<40-m;u++)
{*name[u]=*namecopyed[u];
if(n<m)
n++;}
char t=name[];
cout<<"E-mail: "<<t<<namecopyed<<"@ndu.edu.lb\n";
};
};
A print function to print all the attributes of an advisor: id, name, rank, password and nbrAdvisees. This function should also generate and print the email of the advisor. You should generate the email as follows: the first letter of the first name, followed by the last name, followed by “@ndu.edu.lb”. For example, the email of James Bond would be JBond@ndu.edu.lb
121 In member function `void advisor::print()':
121 name lookup of `n' changed for new ISO `for' scoping
using obsolete binding at `n' using obsolete binding at `n'
118 using obsolete binding at `n'
127 expected primary-expression before ']' token
118 C:\Users\Ray\Desktop\university\CSC 213\assignment 1(part2).cpp using obsolete binding at `n'
Here are the errors I see:
Line 66: getId is declared as returning float, but returns int.
Line 117: The size of namecopyed is not a constant.
Line 119: This statement is a no-op.
Line 121: This statement makes no sense. Why are you taking the address of name on each side? Isn't this what you want?
name[u]=name[n];
Line 123: Again, this statement makes no sense. You're trying to use a character as a pointer.
Line 124: n is undefined. n went out of scope at the end of of it's for loop (line 119).