Rabu, 21 Maret 2012

source kode c++ program menghitung nilai dengan array


//Program menghitung nilai mahasiswa//
//Nama           haryono//
#include
#include
#include
main()
{
char masuk, ulang, nama_mhs[20][30];
int i,j;
float tugas[20], quis[20], uts[20],uas[20], hasil[20];
do{
clrscr();
gotoxy(20,1);printf ("*******************************************");
gotoxy(25,2);printf ("    PROGRAM MENGOLAH NILAI MAHASISWA");
gotoxy(20,3);printf ("         MATA KULIAH STATISTIK");
gotoxy(20,4);printf ("********************************************");
gotoxy(20,15);printf ("UNTUK MULAI OLAH TEKAN ENTER");
printf ("\a");
fflush(stdin);
scanf("%c", &masuk);
clrscr();
gotoxy(20,1);printf("INPUT DATA \n");
printf("Jumlah mahasiswa : ");scanf("%d", &j);
for(i=1;i<=j;i++){
printf("\ndata mahasiswa ke %d \n", i);
printf("Nama Mahasiswa  : ");scanf("%s", &nama_mhs[i]);fflush(stdin);
printf("\Nilai Tugas    : ");scanf("%f", &tugas[i]);fflush(stdin);
printf("\Nilai Quis     : ");scanf("%f", &quis[i]); fflush(stdin);
printf("\Nilai UTS      : ");scanf("%f", &uts[i]);
printf("\Nilai UAS      : ");scanf("%f", &uas[i]);
hasil[i] = (tugas[i] * 0.15) + (quis[i] * 0.20) + (uts[i] * 0.30) + (uas[i] *0.35);
}
clrscr();

printf("PROGRAM MENGOLAH NILAI MAHASISWA \n");

printf("       Mata kuliah STATISTIK \n");
printf("*************************************************************************\n");
printf(" No  Nama                        Nilai                     \n");
printf("                    ---------------------------------------------------\n");
printf("                             tugas    quis    UTS    UAS     Angka    Huruf \n");
printf("*************************************************************************\n");
for(i=1;i<=j;i++){
if (hasil[i] >= 80){
printf(" %d   %s          %.2f    %.2f     %.2f   %.2f           %.2f      A     \n", i,nama_mhs[i], tugas[i], quis[i], uts[i],uas[i], hasil[i]);
}
else if (hasil[i] < 80 && hasil[i] >= 70){
printf(" %d   %s          %.2f    %.2f     %.2f   %.2f     %.2f            B     \n", i,nama_mhs[i], tugas[i], quis[i], uts[i],uas[i], hasil[i]);
}
else if (hasil[i] < 70 && hasil[i] >= 56){
printf(" %d   %s          %.2f    %.2f     %.2f   %.2f     %.2f            C     \n", i,nama_mhs[i], tugas[i], quis[i], uts[i],uas[i], hasil[i]);
}
else if (hasil[i] < 55 && hasil[i] >= 46){
printf(" %d   %s                   %.2f    %.2f     %.2f   %.2f              %.2f      D     \n", i,nama_mhs[i], tugas[i], quis[i], uts[i],uas[i], hasil[i]);
}
else{
printf(" %d   %s          %.2f        %.2f        %.2f   %.2f     %.2f      E   \n", i,nama_mhs[i], tugas[i], quis[i], uts[i],uas[i], hasil[i]);
}
}
printf("*************************************************************************\n");
printf ("\a");
fflush(stdin);
scanf("%c", &ulang);
}
while(ulang);
return 0;
}

0 komentar:

Posting Komentar

komen aja sesuka loe...
OK!!!

 
Copyright © ajo loepus
Blogger Theme by BloggerThemes Sponsored by Internet Entrepreneur