Saturday, June 26, 2010

CS201 Ass # 4 Sol

Problem Statement: Student class

You are required to write a class named “Student “. Student class has the following data members
·
Name
·
Roll Number
·
Semester
·
CGPA

Student class should have
Default and overloaded constructors
Getter and setter functions
A display function that will display the values of data members of an object
You are required to create two objects of student class. One object should be initialized with default constructor, and second object should be initialized with overloaded constructor.
Then you should display the values of both objects using display() function.

Solution:-


#include
using namespace std;
class Student{
private:
string name;
int rollNumber;
string semester;
double cgpa;

public:
Student(string n,int r,string s,double c )
{name=n;
rollNumber=r;
semester=s;
cgpa=c;
}
Student()
{name="";
rollNumber=0;
semester="Summer 2010";
cgpa=4.0;
}


string get_semester()
{return semester;
}
void set_semester(string n)
{semester=n;
}
void set_roll(int n)
{rollNumber=n;
}
int get_roll()
{return rollNumber;
}
void set_name(string n)
{name=n;
}
string get_name()
{return name;
}
void set_cgpa(double n)
{cgpa=n;
}

double get_cgpa()
{return cgpa;
}
 void print()
{cout<<"Student Information\n";
cout<<"Name: "<

Please do make changes in these assignment otherwise every one who copy this assignment as it is will awarded zero marks 

NOTE: - These Assignments OR Quiz are just for idea, so kindly don't copy it, after viewing it make your own. Thanks We always try our best to upload 100% correct solution BUT it is requested that you kindly review it before submission, please BEST OF LUCK, Thanks to those students those send me Assignments and quizzes. If you have any Assignment and quiz kindly send at jamilbookcenter@yahoo.com

No comments:

Post a Comment