#include <iostream>
#include<string.h>
using namespace std;
class student
{
public:
char fname[20],lname[20];
int phno;
void getdata()
{
cin>>fname;
cin>>lname;
cin>>phno;
}
void display()
{
cout<<"First Name: "<<fname<<endl;
cout<<"Last Name: "<<lname<<endl;
cout<<"Phone: "<<phno<<endl;
}
};
class grade:public student
{
public:
char g[5];
int score;
grade()
{
strcpy(g,"0");
score=0;
}
void calculate()
{cin>>score;
if (score <40)
strcpy(g,"D");
else if(score>=40 && score<60)
strcpy(g,"B");
else if(score>=60 && score<75)
strcpy(g,"A");
else if(score>=75 && score<90)
strcpy(g,"E");
else
strcpy(g,"O");
}
void disp()
{
cout<<"Grade: "<<g<<endl;
}
};
int main() {
grade o;
o.getdata();
o.display();
o.calculate();
o.disp();
return 0;
}
#include<string.h>
using namespace std;
class student
{
public:
char fname[20],lname[20];
int phno;
void getdata()
{
cin>>fname;
cin>>lname;
cin>>phno;
}
void display()
{
cout<<"First Name: "<<fname<<endl;
cout<<"Last Name: "<<lname<<endl;
cout<<"Phone: "<<phno<<endl;
}
};
class grade:public student
{
public:
char g[5];
int score;
grade()
{
strcpy(g,"0");
score=0;
}
void calculate()
{cin>>score;
if (score <40)
strcpy(g,"D");
else if(score>=40 && score<60)
strcpy(g,"B");
else if(score>=60 && score<75)
strcpy(g,"A");
else if(score>=75 && score<90)
strcpy(g,"E");
else
strcpy(g,"O");
}
void disp()
{
cout<<"Grade: "<<g<<endl;
}
};
int main() {
grade o;
o.getdata();
o.display();
o.calculate();
o.disp();
return 0;
}
Operator Overloading
ReplyDeleteQ. 35: Unary
#include
using namespace std;
int x,y,x1,y1;
class data{
public:
void setdata(){
cin>>x>>y;
cin>>x1>>y1;
}
void operator -( ){
if(x>0){
cout<<"-"<0){
cout<<"-"<0){
cout<<" -"<<y1;
}else
cout<<" "<<(y1-y1)-y1;
}
};
int main(){
data ob;
ob.setdata();
ob.operator -();
return 0;
}
not working
Deletebro 85% evaluation
ReplyDelete#include
ReplyDelete#include
using namespace std;
class Student
{
public:
char fname[20],lname[20];
int phno;
void getdata()
{
cin>>fname;
cin>>lname;
cin>>phno;
}
void display()
{
cout<<"First Name: "<>score;
if (score <40)
g='D';
else if(score>=40 && score<60)
g='C';
else if(score>=60 && score<75)
g='B';
else if(score>=75 && score<90)
g='A';
else
g='O';
return g;
}
void disp()
{
cout<<"Grade: "<<calculate()<<endl;
}
};
int main() {
Grade o;
o.getdata();
o.display();
o.calculate();
o.disp();
return 0;
}
How can anybody be so wrong............
Delete#include
ReplyDelete#include
using namespace std;
class student
{
public:
char fname[20],lname[20];
int phno;
void getdata()
{
cin>>fname;
cin>>lname;
cin>>phno;
}
void display()
{
cout<<"First Name: "<>score;
if (score <40)
strcpy(g,"D");
else if(score>=40 && score<60)
strcpy(g,"C");
else if(score>=60 && score<75)
strcpy(g,"B");
else if(score>=75 && score<90)
strcpy(g,"A");
else
strcpy(g,"O");
}
void disp()
{
cout<<"Grade: "<<g<<endl;
}
};
int main() {
grade o;
o.getdata();
o.display();
o.calculate();
o.disp();
return 0;
}
//Works!!!!
ReplyDelete#include
#include
using namespace std;
class Student
{
public:
char fname[20],lname[20];
int phno;
void getdata()
{
cin>>fname;
cin>>lname;
cin>>phno;
}
void display()
{
cout<<"First Name: "<>score;
if (score <40)
strcpy(g,"D");
else if(score>=40 && score<60)
strcpy(g,"C");
else if(score>=60 && score<75)
strcpy(g,"B");
else if(score>=75 && score<90)
strcpy(g,"A");
else if(score>=90 && score<=100)
strcpy(g,"O");
}
void disp()
{
cout<<"Grade: "<<g<<endl;
}
};
int main() {
Grade o;
o.getdata();
o.display();
o.calculate();
o.disp();
return 0;
}
Replace <> with <<
DeleteDoesn't work
DeleteDoesn't work
DeleteWE NEED 100% EVALUATION CODE ANY ONE SEND PLZ
ReplyDeleteelse if(score>=40 && score<60)
ReplyDeletestrcpy(g,"B");
else if(score>=60 && score<75)
strcpy(g,"A");
else if(score>=75 && score<90)
strcpy(g,"E");
else
strcpy(g,"O");
in the place of this paste this
if (score <40)
strcpy(g,"D");
else if(score<=40 && score<60)
strcpy(g,"C");
else if(score<=60 && score<75)
strcpy(g,"B");
else if(score<=75 && score<90)
strcpy(g,"A");
else
strcpy(g,"O");
#include
ReplyDelete#include
using namespace std;
class student
{
public:
char fname[20],lname[20];
int phno;
void getdata()
{
cin>>fname;
cin>>lname;
cin>>phno;
}
void display()
{
cout<<"First Name: "<>score;
if (score <40)
strcpy(g,"D");
else if(score>=40 && score<60)
strcpy(g,"C");
else if(score>=60 && score<75)
strcpy(g,"B");
else if(score>=75 && score<90)
strcpy(g,"A");
else
strcpy(g,"O");
}
void disp()
{
cout<<"Grade: "<<g<<endl;
}
};
int main() {
Grade o;
o.getdata();
o.display();
o.calculate();
o.disp();
return 0;
}
#include
ReplyDelete#include
using namespace std;
class student
{
public:
char fname[20],lname[20];
int phno;
void getdata()
{
cin>>fname;
cin>>lname;
cin>>phno;
}
void display()
{
cout<<"First Name: "<>score;
if (score <40)
strcpy(g,"D");
if (score <40)
strcpy(g,"D");
else if(score<=40 && score<60)
strcpy(g,"C");
else if(score<=60 && score<75)
strcpy(g,"B");
else if(score<=75 && score<90)
strcpy(g,"A");
else
strcpy(g,"O");
}
void disp()
{
cout<<"Grade: "<<g<<endl;
}
};
int main() {
grade o;
o.getdata();
o.display();
o.calculate();
o.disp();
return 0;
}
not working
ReplyDelete