-
Notifications
You must be signed in to change notification settings - Fork 0
/
gpa.c
132 lines (119 loc) · 2.83 KB
/
gpa.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
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
#include <stdio.h>
#include <stdlib.h>
/*************GLOBAL VARIABLES*************/
int courseNumber;
char** courseName;
char** harf;
double sum, dev, cGPA;
int kredi[30];
struct course {
char courseName[8];
char harf[2];
int kredi;
};
struct course Course[45];
/******************************************/
/*INITIALIZE G.V.*/
int courseNumber = 0;
/**********/
double harfConverter(char harf){
switch(harf){
case 'A':
return 2.0;
case 'B':
return 1.5;
case 'C':
return 1.0;
case 'D':
return 0.5;
case 'F':
return 0.0;
default :
return -1.0;
}
}
void printTable(int var){
int i = 0;
if(var == 1){
printf("\n");
for(i = 0; i < 24; i++) printf("*");
printf("\n*By Miraç Akif Merttürk*\n");
for(i = 0; i < 24; i++) printf("*");
printf("\n");
printf("*Lütfen inputları şu *\n*şekilde giriniz : *\n");
printf("*CourseName : *\n*kredi_sayısı harfNotu,*\n");
printf("* ':' ve ',' unutmayın *\n*en sona ise ',' yerine*\n");
printf("* '.' (nokta) koyunuz *\n");
for(i = 0; i < 23; i++) printf("*");
}
else {
for(i = 0; i < 2; i++){
printf("*");
for(i = 0; i < 22; i++) printf(" ");
printf("*\n");
}
for(i = 0; i < courseNumber; i++){
printf("*%s : %c%c - %d kredi*\n", Course[i].courseName, Course[i].harf[0], Course[i].harf[1], Course[i].kredi);
}
if(cGPA >= 2.00) {
printf("\n");
for(i = 0; i < 24; i++) {printf("*");}
printf("\n*");
for(i = 0; i < 22; i++){printf(" ");}
printf("*\n");
printf("* cGPA = %.2f ! *\n*", cGPA);
for(i = 0; i < 22; i++){printf(" ");}
printf("*\n");
printf("******* AŞMIŞSIN *******\n");
printf("\n");
printf(" ~~ \n\n");
}
else {
printf("\n");
for(i = 0; i < 24; i++) {printf("*");}
printf("\n*");
for(i = 0; i < 22; i++){printf(" ");}
printf("*\n");
printf("*------- LOOSER -------*\n");
printf("* cGPA = %.2f ! *\n*", cGPA);
for(i = 0; i < 22; i++){printf(" ");}
printf("*\n");
printf("*Hayat kısa keyfine bak*\n");
printf("\n");
}
}
}
int main() {
int i = 0, j = 0;
char temp = 'i';
sum = 0;
dev = 0;
printTable(1);
while(temp != '.'){
scanf(" %c", &temp);
for(j = 0; 1; j++){
if((temp != ':') && (temp != '.')) {
if(temp == ',') {
scanf(" %c", &temp);
}
else ;
Course[i].courseName[j] = temp;
scanf(" %c", &temp);
}
else if(temp == ':'){
for(; j < 7; j++) {Course[i].courseName[j] = ' ';}
Course[i].courseName[j] = '\0';
scanf(" %d %c %c %c", &Course[i].kredi, &Course[i].harf[0], &Course[i].harf[1], &temp);
dev = dev + Course[i].kredi;
sum = sum + Course[i].kredi * (harfConverter(Course[i].harf[0]) + harfConverter(Course[i].harf[1]));
courseNumber++;
i++;
break;
}
else break;
}
}
cGPA = sum / dev;
printTable(4);
return 0;
}