-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStudent Client Code.cpp
68 lines (64 loc) · 1.43 KB
/
Student Client Code.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include<iostream>
#include "Student.h"
using namespace std;
int main()
{
const int maxStudent = 5;
Student object[maxStudent]=
{
Student("alishba", 123, 50.0),
Student("ali", 713, 10.8),
Student("ahmed", 2022, 45.5),
Student("ahsan", 100, 23.75)
};
Student *ptr = object;
int choice;
do{
cout << "\n1.Add new student\n2.Display details of students\n3.Find student with highest marks\n4.Exit\n";
cin >> choice;
switch (choice)
{
case 1:
{
char* name;
float marks;
int rollNumber;
Student ptr[maxStudent + 1];
for (int i = 0; i < maxStudent; i++)
{
ptr[i] = object[i];
}
cout << "Enter name :";
cin>>name;
cin.ignore();
cout << "Enter roll number:";
cin >> rollNumber;
cout << "Enter marks:";
cin >> marks;
object[maxStudent].setName(name);
object[maxStudent].setMarks(marks);
object[maxStudent].setRollNumber(rollNumber);
cout << "Student added!\n" << endl;
break;
}
case 2:
for (int i = 0; i < maxStudent; i++)
{
cout << "\nRecord of " << i + 1 << " student:\n";
ptr[i].displayRecord();
}
break;
case 3:
{
int index;
index = object[0].studentWithHighestMarks(object, maxStudent);
cout << object[index].getName() << " got highest marks " << object[index].getMarks() << endl;
break;
}
case 4:
break;
}
} while (choice!=4);
system("pause");
return 0;
}