-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClass Contains various members.cpp
57 lines (46 loc) · 1.2 KB
/
Class Contains various members.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
#include <iostream>
#include <string>
using namespace std;
class Student {
private:
string Name;
int SCD;
float GPA;
string Phone;
string Address;
public:
void input(){
cout << "Enter Name: ";
cin.ignore();
getline(cin, Name);
cout << "Enter SCD: ";
cin >> SCD;
cout << "Enter GPA: ";
cin >> GPA;
cout << "Enter Phone: ";
cin.ignore();
getline(cin, Phone);
cout << "Enter Address: ";
getline(cin, Address);
}
void print() const {
cout << "\nStudent Information:\n";
cout << "Name: " << Name << "\nSCD: " << SCD << "\nGPA: " << GPA
<< "\nPhone: " << Phone << "\nAddress: " << Address << "\n";
}
};
int main() {
int n;
cout << "Enter number of student : ";
cin >> n;
int numberOfStudents = n;
Student students[numberOfStudents];
for (int i = 0; i < numberOfStudents; ++i) {
cout << "\nEnter details for Student " << i + 1 << ":\n";
students[i].input();
}
for (int i = 0; i < numberOfStudents; ++i) {
students[i].print();
}
return 0;
}