-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUjian Akhir Semester.cpp
189 lines (163 loc) · 2.94 KB
/
Ujian Akhir Semester.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#include <iostream>
#include <conio.h>
#include <cstdlib>
#include <cstring>
using namespace std;
//Deklarasi variabel
string nama ['x'];
long nim ['x'];
int tm ['x'];
int uts ['x'];
int uas ['x'];
float final ['x'];
string grade ['x'];
int i = 0;
int x;
//Pilihan 1
void input_data()
{
system("cls");
cout << "Masukkan jumlah mahasiswa : ";
cin >> x;
cout << endl;
while (i < x)
{
cout << "Masukkan nama mahasiswa : ";
cin >> nama[i];
cout << "Masukkan NIM mahasiswa : ";
cin >> nim[i];
cout << endl;
cout << "Masukkan nilai tugas : ";
cin >> tm[i];
cout << "Masukkan nilai UTS : ";
cin >> uts[i];
cout << "Masukkan nilai UAS : ";
cin >> uas[i];
final[i] = 0.3 * tm[i] + 0.3 * uts[i] + 0.4 * uas[i];
cout << "Nilai akhir : " << final[i];
cout << endl;
if (final[i] <= 100 && final[i] >= 81)
{
grade[i] = "A";
}
else if (final[i] <= 80 && final[i] >= 71)
{
grade[i] = "B";
}
else if (final[i] <= 70 && final[i] >= 51)
{
grade[i] = "C";
}
else
{
grade[i] = "D";
}
cout << "Grade : " << grade[i] << endl;
cout << endl;
i++;
}
}
//Pilihan 2
void display()
{
system("cls");
cout << "Nama \t\t NIM \t\t TM \t\t UTS \t\t UAS \t\t Final \t\t Grade" << endl;
for (i = 0; i < x; i++)
{
cout << nama[i] << " \t\t " << nim[i] << " \t\t " << tm[i] << " \t\t " << uts[i] << " \t\t " << uas[i] << " \t\t " << final[i] << " \t\t " << grade[i] << endl;
}
getch();
}
//Pilihan 3
void sort()
{
int j;
int k;
int temp;
for (j = 0; j < x; j++)
{
for (k = (x-1); k > 0; k--)
{
if (nim[k] < nim[k-1])
{
temp = nim[k];
nim[k] = nim[k-1];
nim[k-1] = temp;
}
}
}
}
//Pilihan 4
void search()
{
long search_nim;
bool isFound = false;
system("cls");
cout << "Masukkan NIM mahasiswa yang ingin dicari: ";
cin >> search_nim;
cout << endl;
for (i = 0; i <= x; i++)
{
if (search_nim == nim[i])
{
cout << "Nama mahasiswa : " << nama[i] << endl;
cout << "Nilai tugas : " << tm[i] << endl;
cout << "Nilai UTS : " << uts[i] << endl;
cout << "Nilai UAS : " << uas[i] << endl;
cout << "Nilai akhir : " << final[i] << endl;
cout << "Grade : " << grade[i];
isFound = true;
}
else if (i == x && isFound == false)
{
cout << "NIM tidak terdaftar";
}
}
getch();
}
//Main Program
int main()
{
int menu;
do
{
system("cls");
cout << "1. Input data mahasiswa" << endl;
cout << "2. Tampilkan data mahasiswa" << endl;
cout << "3. Sorting nilai" << endl;
cout << "4. Cari mahasiswa" << endl;
cout << "5. Keluar" << endl;
cout << "Pilihan anda: ";
cin >> menu;
switch (menu)
{
case 1:
{
input_data();
break;
}
case 2:
{
display();
break;
}
case 3:
{
sort();
break;
}
case 4:
{
search();
break;
}
case 5:
{
system ("EXIT");
}
}
}
while (menu != 5);
getch();
return 0;
}