Assalamu'alaikum wr.wb
pada kesempatan kali ini saya akan memposting algoritma menghitung ipk menggunkan Dev c++ :
Analisis :
1. menginputkan jumlah sks dan input nilai dalam bentuk huruf A,B,C,D,E.
2. outputkan akan menghasilkan nilai ipk berdasarkan sks dan nilai huruf yg di inputkan.
Algoritma :
Procedure IPK (input/output npm[15] ::char , jumlahMK :: integer, jumlahSKS::integer)
Deklarasi
a,b,c,n -> integer
jumlahMhs->integer
Deskripsi
int ip;
switch(x) {
case 'A':
ip=4*y;
break;
case 'B':
ip=3*y;
break;
case 'C':
ip=2*y;
break;
case 'D':
ip=1*y;
break;
case 'E':
ip=0*y;
break;
default:
ip=0;
break;
}
return ip;
}
n=0;
float ip_plus,ipp, ippp;
char hitunglagi;
jumlahsks=0;
ippp=0;
jumlahsks=makul.sks*jumlahMK;
ipp= HitungIPK(makul.nilai, makul.sks);
ippp+=ipp;
endfor
for(n=0;n<1;n++);float ip_plus,ipp, ippp;
char hitunglagi;
jumlahsks=0;
ippp=0;
jumlahsks=makul.sks*jumlahMK;
ipp= HitungIPK(makul.nilai, makul.sks);
ippp+=ipp;
endfor
mhs.ipk = ippp/jumlahsks;
write(ipk)
ini dia kodingan dev c++nya :
#include <iostream>
#include<conio.h>
#include<ctype.h>
#include<stdlib.h>
#include<stdio.h>
#include<windows.h>
using namespace std;
int HitungIPK (char x, int y)
{
int ip;
switch(x)
{
case 'A':
ip=4*y;
break;
case 'B':
ip=3*y;
break;
case 'C':
ip=2*y;
break;
case 'D':
ip=1*y;
break;
case 'E':
ip=0*y;
break;
default:
ip=0;
break;
}
return ip;
}
ini dia kodingan dev c++nya :
#include <iostream>
#include<conio.h>
#include<ctype.h>
#include<stdlib.h>
#include<stdio.h>
#include<windows.h>
using namespace std;
int HitungIPK (char x, int y)
{
int ip;
switch(x)
{
case 'A':
ip=4*y;
break;
case 'B':
ip=3*y;
break;
case 'C':
ip=2*y;
break;
case 'D':
ip=1*y;
break;
case 'E':
ip=0*y;
break;
default:
ip=0;
break;
}
return ip;
}
int main()
{
system("color 20");
char npm[15], sem;
int jumlahMK, jumlahMhs, jumlahsks, a,b,c,n;
n=0;
float ip_plus,ipp, ippp;
char hitunglagi;
jumlahsks=0;
ippp=0;
struct mahasiswa
{
char nama[50];
int nim;
char fak[20];
char prodi[25];
float ipk;
};
struct matakuliah
{
char namaMK[25];
char nilai;
int sks;
};
mahasiswa mhs;
matakuliah makul;
cout<<"\t\t\t\t=== Menghitung IPK ===\n\n"<<endl;
cout<<"\t\t\t\tSilahkan masukkan data diri anda\t\t\t"<<endl;
cout<<"\t\t\t\t================================\t\t\t"<<endl<<endl;
do {
cout<<"\t\t\t------------------------------------------------------"<<endl<<endl;
cout<<"\t\t\t\tNama\t: ";
cin>>mhs.nama;
cout<<"\t\t\t\tNim\t: ";
cin>>mhs.nim;
cout<<"\t\t\t\tFakultas: ";
cin>>mhs.fak;
cout<<"\t\t\t\tProdi\t: ";
cin>>mhs.prodi;
cout<<endl;
cout<<"\t\t\t------------------------------------------------------"<<endl<<endl;
cout<<"\t\t\tMasukkan jumlah matakuliah yang akan dihitung: ";
cin>>jumlahMK;
cout<<endl;
for(b=0; b<jumlahMK; b++)
{
cout<<"\t"<<b+1;
cout<<"\t\t\tMasukkan Nama Mata Kuliah\t: ";
cin>>makul.namaMK;
cout<<"\t\t\t\tMasukkan Jumlah SKS : ";
cin>>makul.sks;
cout<<"\t\t\t\tMasukkan nilai MK (A,B,C,D,E)\t: ";
cin>>makul.nilai;
cout<<endl;
jumlahsks=makul.sks*jumlahMK;
ipp= HitungIPK(makul.nilai, makul.sks);
ippp+=ipp;
}
mhs.ipk = ippp/jumlahsks;
cout<<endl<<endl;
cout<<"================================================================ \n";
cout<<"\t\t\tNAMA\t\t: "<<mhs.nama<<endl;
cout<<"\t\t\tNIM\t\t: "<<mhs.nim<<endl;
cout<<"\t\t\tFAKULTAS\t: "<<mhs.fak<<endl;
cout<<"\t\t\tPRODI\t\t: "<<mhs.prodi<<endl;
cout<<"================================================================ \n";
printf("\n");
printf(" KARTU HASIL STUDY\n");
printf("---------------------------------------------------------------\n");
printf("No | Matakuliah | SKS | Nilai Akhir | SKS*Scor\n");
printf("---------------------------------------------------------------\n");
for(n=0;n<1;n++){
cout<<n+1<<"| "<<"\t"<<makul.namaMK<<"\t\t"<<" | "<<jumlahsks<<"\t\t"<<" | "<<mhs.ipk<<"\t\t"<<" | "<<ippp<<endl;
}
getch();
cout<<"================================================================ \n";
cout<<"Jumlah Mata Kuliah\t : "<<jumlahMK<<endl;
cout<<"Jumlah SKS \t\t : "<<jumlahsks<<endl;
cout<<"Jumlah SKS x Nilai\t : "<<ippp<<endl;
cout<<"Indeks Prestasi \t : "<<mhs.ipk<<endl<<endl;
cout<<"HItung lagi (y /n) = ";
cin>>hitunglagi;
}
while(hitunglagi=='y' || hitunglagi=='Y');
system("pause");
return 0;
}
{
system("color 20");
char npm[15], sem;
int jumlahMK, jumlahMhs, jumlahsks, a,b,c,n;
n=0;
float ip_plus,ipp, ippp;
char hitunglagi;
jumlahsks=0;
ippp=0;
struct mahasiswa
{
char nama[50];
int nim;
char fak[20];
char prodi[25];
float ipk;
};
struct matakuliah
{
char namaMK[25];
char nilai;
int sks;
};
mahasiswa mhs;
matakuliah makul;
cout<<"\t\t\t\t=== Menghitung IPK ===\n\n"<<endl;
cout<<"\t\t\t\tSilahkan masukkan data diri anda\t\t\t"<<endl;
cout<<"\t\t\t\t================================\t\t\t"<<endl<<endl;
do {
cout<<"\t\t\t------------------------------------------------------"<<endl<<endl;
cout<<"\t\t\t\tNama\t: ";
cin>>mhs.nama;
cout<<"\t\t\t\tNim\t: ";
cin>>mhs.nim;
cout<<"\t\t\t\tFakultas: ";
cin>>mhs.fak;
cout<<"\t\t\t\tProdi\t: ";
cin>>mhs.prodi;
cout<<endl;
cout<<"\t\t\t------------------------------------------------------"<<endl<<endl;
cout<<"\t\t\tMasukkan jumlah matakuliah yang akan dihitung: ";
cin>>jumlahMK;
cout<<endl;
for(b=0; b<jumlahMK; b++)
{
cout<<"\t"<<b+1;
cout<<"\t\t\tMasukkan Nama Mata Kuliah\t: ";
cin>>makul.namaMK;
cout<<"\t\t\t\tMasukkan Jumlah SKS : ";
cin>>makul.sks;
cout<<"\t\t\t\tMasukkan nilai MK (A,B,C,D,E)\t: ";
cin>>makul.nilai;
cout<<endl;
jumlahsks=makul.sks*jumlahMK;
ipp= HitungIPK(makul.nilai, makul.sks);
ippp+=ipp;
}
mhs.ipk = ippp/jumlahsks;
cout<<endl<<endl;
cout<<"================================================================ \n";
cout<<"\t\t\tNAMA\t\t: "<<mhs.nama<<endl;
cout<<"\t\t\tNIM\t\t: "<<mhs.nim<<endl;
cout<<"\t\t\tFAKULTAS\t: "<<mhs.fak<<endl;
cout<<"\t\t\tPRODI\t\t: "<<mhs.prodi<<endl;
cout<<"================================================================ \n";
printf("\n");
printf(" KARTU HASIL STUDY\n");
printf("---------------------------------------------------------------\n");
printf("No | Matakuliah | SKS | Nilai Akhir | SKS*Scor\n");
printf("---------------------------------------------------------------\n");
for(n=0;n<1;n++){
cout<<n+1<<"| "<<"\t"<<makul.namaMK<<"\t\t"<<" | "<<jumlahsks<<"\t\t"<<" | "<<mhs.ipk<<"\t\t"<<" | "<<ippp<<endl;
}
getch();
cout<<"================================================================ \n";
cout<<"Jumlah Mata Kuliah\t : "<<jumlahMK<<endl;
cout<<"Jumlah SKS \t\t : "<<jumlahsks<<endl;
cout<<"Jumlah SKS x Nilai\t : "<<ippp<<endl;
cout<<"Indeks Prestasi \t : "<<mhs.ipk<<endl<<endl;
cout<<"HItung lagi (y /n) = ";
cin>>hitunglagi;
}
while(hitunglagi=='y' || hitunglagi=='Y');
system("pause");
return 0;
}