#include<iostream>
using namespace std;
class Student{
private:
string name;
int rollNo;
int marks[5];
public:
friend void input();
friend void display();
double totalMarks(){
double total = 0.0;
for(int i=0; i<5; i++){
total += marks[i];
}
return total;
}
bool operator <(Student s1){
if(totalMarks() < s1.totalMarks()){
return true;
}
else{
return false;
}
}
bool operator >( Student s1){
if(totalMarks() > s1.totalMarks()){
return true;
}
else{
return false;
}
}
bool operator <=(Student s1){
if(totalMarks() <= s1.totalMarks()){
return true;
}
else{
return false;
}
}
bool operator >=(Student s1){
if(totalMarks() >= s1.totalMarks()){
return true;
}
else{
return false;
}
}
};
void input(){
Student s;
cout<<"Enter student name\n";
cin>>s.name;
cout<<"Enter the Roll Number\n";
cin>>s.rollNo;
cout<<"Enter the marks for the student\n";
for(int i=0; i<5; i++){
cout<<"Mark "<<(i + 1)<<endl;
cin>>s.marks[i];
}
}
void display(){
Student s;
cout<<"Student name is\t"<<s.name<<endl;
cout<<"Student Roll Number is\t"<<s.rollNo<<endl;
cout<<"The marks for the student are: \n";
for(int i=0; i<5; i++){
cout<<s.marks[i]<<" ";
}
}
int main(){
input();
display();
}
Comments
Leave a comment