-
Notifications
You must be signed in to change notification settings - Fork 0
/
20-42616-1 lab 3 problem 3.cpp
70 lines (61 loc) · 1.48 KB
/
20-42616-1 lab 3 problem 3.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
69
70
#include <iostream>
using namespace std;
struct Student
{
int studentID;
int completeCredits;
double CGPA;
};
int main()
{
struct Student S[10];
int i, n = 0;
bool isUsed[10] = {0};
for(i=0; i<10; i++)
{
cout << " ---------- Please enter the information of " << (i + 1) << "th number student ---------- "<< endl<<endl;
cout<<"Student ID: ";
cin>>n;
if((n >= 0) && (n <= 9))
{
if (isUsed[n] == false)
{
S[i].studentID = n;
isUsed[n] = true;
cout<<"Number Of Credit Completed: ";
cin>>S[i].completeCredits;
cout<<"CGPA: ";
cin>>S[i].CGPA;
}
else
{
cout << "Student ID has already been used. Try different ID !!" << endl;
i--;
}
}
else
{
cout << "Student ID from 0-9 only." << endl;
i--;
}
cout<<endl;
}
cout<<"\nStudent ID who have earn CGAP more than 3.75 : ";
for(i=0;i<10;i++)
{
if(S[i].CGPA > 3.75)
{
cout<<S[i].studentID<<endl;
}
}
cout<<"\nStudent ID who have completed more than 50 credits : ";
for(i=0;i<10;i++)
{
if(S[i].completeCredits > 50)
{
cout<<S[i].studentID<<endl;
}
}
cout<<endl<<endl;
return 0;
}