Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem Statement:Student class You are required to write a class named “Student

ID: 3619371 • Letter: P

Question

Problem Statement:Student class

You are required to write a class named “Student “.Student class has the following data members

·        Name

·        RollNumber

·        Semester

·        CGPA

Student class should have

Problem Statement:Student class

You are required to write a class named “Student “.Student class has the following data members

·        Name

·        RollNumber

·        Semester

·        CGPA

Student class should have

  • Default andoverloaded constructors
  • Getter andsetter functions
  • A displayfunction that will display the values of data members of anobject
  • You arerequired to create two objects of student class. One object shouldbe initialized with default constructor, and second object shouldbe initialized with overloaded constructor.
  • Then youshould display the values of both objects using display()function.

Explanation / Answer

#include<iostream> #include<conio> #include<string.h> using namespace std; class student {    char name[50];    int Roll_No;    char semester[10];    double gpa;    public:    student(char name1[],int roll_no,charsemester1[],double gpa1)    {    strcpy(name,name1);    Roll_No=roll_no;      strcpy(semester,semester1);    gpa=gpa1;    }    student()    //Overloaded constructor    {    strcpy(name,"No name");    Roll_No=0;    strcpy(semester,"NIL");    gpa=0.0;    }    void get()    {    cout<<" Enter Thename of the Student :";    cin>>name;    cout<<" Enter the RollNo of the Student :";    cin>>Roll_No;    cout<<" Enter theSemester of the student:";    cin>>semester;    cout<<" Enter the GPAof the Student :";    cin>>gpa;    }    void set(char name1[],int roll_no,charsemester1[],double gpa1)    {    strcpy(name,name1);    Roll_No=roll_no;      strcpy(semester,semester1);    gpa=gpa1;    }    void show()    {    cout<<" Name   :"<<name;    cout<<" Roll No:"<<Roll_No;      cout<<" Semester:"<<semester;    cout<<" GPA    :"<<gpa;    } }; int main() {    student test1; // Totest the no argument constructor    cout<<" Constructorchecking....";    test1.show();    studenttest2("RiseandShine",1,"Final",4.00); //To test the argumentconstructor    cout<<" Overloaded constructorchecking....";    test2.show();    /* student test3;       //To test the get    test3.get();    cout<<" Get FunctionChecking....";    test3.show();    student test4; //To test the setfunctions    test4.set("Hello",2,"Ist",3.9);    cout<<" Show Functionchecking....";    test4.show(); */    getche();    return 0; }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote