BUKU RUJUKAN 1 chapter 14 (Menghitung ipk)
1. Program menghitung IPK dengan DEV C++
2. Analisis :
1. Inputan yang akan digunakan disini adalah, menginputkan jumlah SKS dan Input nilai dalam bentuk huruf A-E.
2. Outpunya akan menghasilkan nilai IPK berdasar SKS dan nilai huruf yang telah di inputkan.
3. Algoritma :
Procedure IPK (input/output matkul[50] ::char , jmk :: integer, bsks::integer)
Deklarasi
i -> integer
bernilai[100]->integer
mutu[100]->integer
Deskripsi
for(i=1;i<=jmk;i++):
read(matkul[i]);
if (matkul[i]=='A') then bnilai[i]=4;
else if (matkul[i]=='B') then bernilai[i]=3;
else if (matkul[i]=='C') then bernilai[i]=2;
else if (matkul[i]=='D') then bernilai[i]=1;
else if (matkul[i]=='E') then bernilai[i]=0;
endif
read(bsks[i]);
if(bsks[i]>=1 && bsks[i]<=4) then bsks[i]= bsks[i];
endif
mutu[i]=bernilai[i]*bsks[i];
endfor
float tmutu=0, tbobot=0;
for(z=1; z<=jmk; z++):
tmutu+=mutu[z];
tbobot+=bsks[z];
endfor
float ipk;
ipk=tmutu/tbobot;
write(ipk).
4. Codingan nya :
#include<iostream>
#include<conio.h>
#include<ctype.h>
#include<stdlib.h>
#include<stdio.h>
#include<windows.h>
using namespace std;
int main(){
int jmk, i, z;
char npm[15], sem;
int bsks[170], bernilai[170], total[170], mutu[170];
char matkul[170], *cbsks[170];
system ("cls");
cout<<"=== Hitung IPK Teknik Informatika ===\n\n";
cout<<"Masukkan NIM: "; cin>>npm;
cout<<"Anda Sekarang Semester: "; cin>>sem;
cout<<"Masukkan Jumlah Mata Kuliah: "; cin>>jmk;
cout<<"===================================\n\n";
cout<<"Masukkan Nilai Anda [A..E]\n";
for(i=1; i<=jmk; i++){
kondisi:
cout<<"Mata kuliah ke "<<i<<" : "; cin>>matkul[i];
if(matkul[i]=='a' || matkul[i]=='A'){
bernilai[i]=4;
}
else if(matkul[i]=='b' || matkul[i]=='B'){
bernilai[i]=3;
}
else if(matkul[i]=='c' || matkul[i]=='C'){
bernilai[i]=2;
}
else if(matkul[i]=='d' || matkul[i]=='D'){
bernilai[i]=1;
}
else if(matkul[i]=='e' || matkul[i]=='E'){
bernilai[i]=0;
}
else{
cout<<"Masukkan HANYA A,B,C,D,E!!\n";
goto kondisi;
}
kond:
cout<<"Bobot SKS [1..4]: "; cin>>bsks[i];
if(bsks[i]>=1 && bsks[i]<=4){
bsks[i]=bsks[i];
}
else{
cout<<"Masukkan HANYA Angka 1-4!!\n";
goto kond;
}
mutu[i]=bernilai[i]*bsks[i];
}
cout<<"\n\nHASIL\n";
float tmutu=0, tbobot=0;
for(z=1; z<=jmk; z++){
tmutu+=mutu[z];
tbobot+=bsks[z];
}
float ipk;
ipk=tmutu/tbobot;
cout<<"========================\n";
cout<<"\nNPM: "<<npm;
cout<<"\nSemester: "<<sem;
cout<<"\nJumlah Mata Kuliah: "<<jmk;
cout<<"\nTotal Mutu: "<<tmutu;
cout<<"\nTotal SKS: "<<tbobot;
cout<<"\nTotal IPK: "<<ipk;
cout<<"\n\n========================";
getch();
return 0;
}
5. Running nya :
0 komentar:
Posting Komentar