SUBJECT: OOP Programming Language: C++   Write a function to search for student details from file using the enrollment of student.   Code: #include #include using namespace std;   #define MAX 10

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

SUBJECT: OOP

Programming Language: C++

 

Write a function to search for student details from file using the enrollment of student.

 

Code:

#include <iostream>

#include <conio.h>

using namespace std;

 

#define MAX 10

 

class student

{

private:

            char  name[30];

            char  sec[30];

            char  sem[30];

            int course1M, course2M, course3M;

            int   EnrollNo;

            int   total;

            float avg;

            char Grade;

 

public:

            student()

            {

                        EnrollNo = 0;

                        course1M = 0;

                        course2M = 0;

                        course3M = 0;

                        total = 0;

                        avg = 0;

            }

 

            void SetDetails();

            void GetDetails();

            float grade(float avg);

 

};

 

void student::SetDetails()

{

            cout << "Enter student name: ";

            cin >> name;

            cout << "Enter Enrollment number: ";

            cin >> EnrollNo;

            cout << "Enter semester: ";

            cin >> sem;

            cout << "Enter Section: ";

            cin >> sec;

            cout << "Enter course 1 mark  out of 100: ";

            cin >> course1M;

            cout << "Enter course 2 mark  out of 100: ";

            cin >> course2M;

            cout << "Enter course 3 mark  out of 100: ";

            cin >> course3M;

 

            total = course1M + course2M + course3M;

            avg = total / 3;

            Grade = grade(avg);

 

}

float student::grade(float avg)

{

            if (avg >= 90 && avg <= 100)

                        return 'A';

            else if (avg >= 80 && avg <= 89)

                        return 'B';

            if (avg >= 70 && avg <= 79)

                        return 'C';

            if (avg >= 60 && avg <= 69)

                        return 'D';

            if (avg >= 50 && avg <= 59)

                        return 'E';

            if (avg <= 49)

                        return 'F';

 

}

 

void student::GetDetails(){

            cout << "\nStudent details:";

            cout << "\nName:" << name;

            cout << "\nEnrollment Number:" << EnrollNo;

            cout << "\nSection:" << sec;

            cout << "\nSemester:" << sem;

            cout << "\nTotal:" << total;

            cout << "\nAverage:" << avg;

            cout << "\nGrade: " << Grade;

}

 

int main()

{

            student stu[MAX];

            int n;

 

            cout << "Enter total number of students: ";

            cin >> n;

 

            for (int i = 0; i< n; i++){

                        cout << "Enter details of student " << i + 1 << ":\n";

                        stu[i].SetDetails();

            }

 

            cout << endl;

 

            for (int i = 0; i< n; i++){

                        cout << "Details of student " << (i + 1) << ":\n" << endl;

                        stu[i].GetDetails();

            }

_getch();

return 0;

}

Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Concept of pointer parameter
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education