0% found this document useful (0 votes)
35 views4 pages

OOP Assignment No. 23

Uploaded by

fairykomal993
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views4 pages

OOP Assignment No. 23

Uploaded by

fairykomal993
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

COMSATS University Islamabad,

Sahiwal Campus.

Assignment # 1

Subject: Object Oriented Programming

Submitted to: Sir Fayez Afzaal

Submitted by: Amina Arshad

Registration No: Sp23-BCS-190

Date: 27/2/24
Program:
Write a class student with data members student name, roll no., semester no., course
name, marks, grade and make them as private. Write member functions with two
constructors one must be parameterized that assigns values to the data members of the
class. One member function get_student_data() should get the student data from the
user. Display_quiz_grade() function should display the student’s grade according to
marks. You have to take three students’ data one from user and two from constructors
that initializes students’ data.
Output view
Enter student1 data
Enter student name = Fayez Afzaal
Enter roll no. = FA18-RCS-010-Section (A)
Enter semester no. = 2
Enter course name= OOP
Your marks is = 10
Your grade is = A

Solution:
#include<iostream>
using namespace std;
class Students{
private:
string name;
int roll_no;
int semester_no;
string course_name;
int marks;
public:
void studentInfo(){
cout<<"Enter student name= "<<name<<endl;
cout<<"Enter student roll_no= "<<roll_no<<endl;
cout<<"Enter student semester_no= "<<semester_no<<endl;
cout<<"Enter student course_name= "<<course_name<<endl;
cout<<"Your Marks= "<<marks<<endl;
cout<<"Your Grade=";

}
void get_student_data(){

cout<<"Enter student name= "<<endl;


cin>>name;
cout<<"Enter student roll_no= "<<endl;
cin>>roll_no;
cout<<"Enter student semester_no= "<<endl;
cin>>semester_no;
cout<<"Enter student course_name= "<<endl;
cin>>course_name;
cout<<"Enter marks=";
cin>>marks;
}
void Display_quiz_grade(){
if(marks>=90&&marks<=100){
cout<<"A\n"<<endl;
}
else if(marks>=80&&marks<=89){
cout<<"B\n"<<endl;
}
else if(marks>=70&&marks<=79){
cout<<"C\n"<<endl;
}
else if(marks<=59){
cout<<"D\n"<<endl;
}
else{
cout<<"fail\n"<<endl;
}

}
Students(string name,int roll,int semester,string course,int mark):

name(name),roll_no(roll),semester_no(semester),course_name(course),marks(mark){
}
Students()
{
}
};
int main(){
Students s1("zara",45,3,"oop",90); Students s2("banze",53,3,"oop",60);
Students s3;
s3.get_student_data();
cout<<"\nStudent1 data\n"<<endl;
s1.studentInfo();
s1.Display_quiz_grade();
cout<<"Student2 data\n"<<endl;
s2.studentInfo();
s2.Display_quiz_grade();
cout<<"Student3 data\n"<<endl;
s3.studentInfo();
s3.Display_quiz_grade();
}
Output:

You might also like