-
Notifications
You must be signed in to change notification settings - Fork 0
/
struct8.c
72 lines (65 loc) · 2.08 KB
/
struct8.c
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
#include <stdio.h>
typedef struct {
char name[50];
char scorechar;
int scoreWork, scoreUTS, scoreUAS, scoreFin;
} collage;
int i;
void input(collage *, int *);
void tampil(collage *, int *);
main() {
collage data[7];
int n;
puts("MENGHITUNG NILAI AKHIR\nMATA KULIAH KONSEP PEMROGRAMAN\n");
printf("Berapa jumlah mahasiswa ? ");
scanf("%d", &n);
printf("\nMasukkan DATA Mahasiswa\n");
input(data, &n);
tampil(data, &n);
}
void input(collage *px, int *py) {
for (i = 0; i < *py; i++) {
printf("\nMahasiswa ke-%d\n", i + 1);
fflush(stdin);
printf("Nama\t\t: ");
gets((px + i)->name);
fflush(stdin);
printf("Nilai tugas\t: ");
scanf("%d", &(px + i)->scoreWork);
printf("Nilai uts\t: ");
scanf("%d", &(px + i)->scoreUTS);
printf("Nilai uas\t: ");
scanf("%d", &(px + i)->scoreUAS);
(px + i)->scoreFin = (0.2 * (px + i)->scoreWork) + (0.4 * (px + i)->scoreUTS) + (0.4 * (px + i)->scoreUAS);
fflush(stdin);
if ((px + i)->scoreFin >= 80)
(px + i)->scorechar = 'A';
else if (((px + i)->scoreFin < 80) && ((px + i)->scoreFin >= 70))
(px + i)->scorechar = 'B';
else if (((px + i)->scoreFin < 70) && ((px + i)->scoreFin >= 60))
(px + i)->scorechar = 'C';
else if (((px + i)->scoreFin < 60) && ((px + i)->scoreFin >= 50))
(px + i)->scorechar = 'D';
else
(px + i)->scorechar = 'E';
fflush(stdin);
}
}
void tampil(collage *px, int *py) {
puts("\t\t\tDAFTAR NILAI\n\t\tMATAKULIAH KONSEP PEMROGRAMAN");
puts("---------------------------------------------------------------------");
puts("No\tNama\t\t\t\tNilai\t\t\tGrade");
puts(" \tMahasiswa\t\tTugas\tUTS\tUAS\tAkhir\t");
puts("---------------------------------------------------------------------");
for (i = 0; i < *py; i++) {
printf("%d\t%s\t\t%d\t%d\t%d\t%d\t%c\n", i + 1,
(px + i)->name,
(px + i)->scoreWork,
(px + i)->scoreUTS,
(px + i)->scoreUAS,
(px + i)->scoreFin,
(px + i)->scorechar);
}
puts("---------------------------------------------------------------------");
printf("\nTotal Mahasiswa = %d\n", *py);
}