Engineering Counselling

#include <iostream>
using namespace std;

class Counselling{
  int num, m1, m2, m3;
  string name;
public:
  void read(){
    cin >> num >> name >> m1 >> m2 >> m3;
  }
 
  friend class enggstudent; 
};

class enggstudent{
  float co;
  int tot;
public:
  void cutoff(Counselling c){
    tot = c.m1+c.m2+c.m3;
    co = (tot)/3.0;       
  }
  void display(Counselling c){
    cutoff(c);
    cout << c.num << " " << c.name << " ( " << c.m1 << " " << c.m2 << " " << c.m3 << " ) " << tot << " " << co << endl;
  }
};

int main() {
  int n;
  cin >> n;
  Counselling c;
  enggstudent ceg;
  cout << "Number Name Marks Total Cutoff" << endl;
  for(int i=0; i<n; i++){
    c.read();
    ceg.cutoff(c);
    ceg.display(c);
  }
return 0;
}

No comments:

Post a Comment