Anda di halaman 1dari 7

C++ "coding mencari IP mahasiswa"

Sumber :
http://stmikputerabatam.blogspot.com/2009/11/c-coding-mencari-ipmahasiswa.html
#include
#include
#include
class mahasiswa
{
private:
char nama_mk[30];
char huruf;
int jumlah_mk;
int sks;
int bobot;
double nilai_absen;
double nilai_tugas;
double nilai_uts;
double nilai_uas;
double hasil;
public:
void inisialisasi();
};
int main()
{
mahasiswa data[100];
int jumlah_mhs;
char nama[25];
char nim[7];
cout<<"=================================================="<
cout<<" STMIK PUTERA BATAM INFORMATIKA "<
cout<<"=================================================="<
cout<<"Masukkan Jumlah Mahasiswa : "; cin>>jumlah_mhs;
cout<
for (int i=1;i<=jumlah_mhs;i++)
{
cout<<"Mahasiswa Ke-"<<
cout<<"NIM : ";cin>>nim;
cout<<"Nama Mahasiswa : ";cin>>nama;
cout<
data[i].inisialisasi();
cout<
}
return 0;

}
void mahasiswa::inisialisasi()
{
mahasiswa data[100];
cout<<"Jumlah Mata Kuliah : ";cin>>jumlah_mk;
cout<
for(int j=1;j<=jumlah_mk;j++)
{
cout<<"Mata kuliah : ";cin>>data[j].nama_mk;
cout<<"SKS mata kuliah : ";cin>>data[j].sks;
l1:cout <<"Masukkan nilai absen : "; cin >> data[j].nilai_absen;
if ((data[j].nilai_absen >100)||(data[j].nilai_absen <0))
{
cout<<"Maaf!!! nilai dalam Skala 0-100 \n";
cout<<"silahkan ulangi lagi \n";
goto l1;
}
l2:cout <<"Masukkan nilai tugas : "; cin >> data[j].nilai_tugas;
if ((data[j].nilai_tugas >100)||(data[j].nilai_tugas <0))
{
cout<<"Maaf!!! nilai dalam Skala 0-100 \n";
cout<<"silahkan ulangi lagi \n";
goto l2;
}
l3:cout <<"Masukkan nilai UTS : "; cin >> data[j].nilai_uts;
if ((data[j].nilai_uts >100)||(data[j].nilai_uts <0))
{
cout<<"Maaf!!! nilai dalam Skala 0-100 \n";
cout<<"silahkan ulangi lagi \n";
goto l3;
}
l4:cout <<"Masukkan nilai UAS : "; cin >> data[j].nilai_uas;
if ((data[j].nilai_uas >100)||(data[j].nilai_uas <0))
{
cout<<"Maaf!!! nilai dalam Skala 0-100 \n";
cout<<"silahkan ulangi lagi \n";
goto l4;
}
// Penginputan nilai murni
data[j].hasil=(data[j].nilai_absen*0.1)+(data[j].nilai_tugas*0.2)+(data[j].nilai_uts*0.3)+
(data[j].nilai_uas*0.4);
// pengkonfersian hasil keseluruhan kedalam nilai huruf
if (data[j].hasil >= 80)
{
data[j].huruf = 'A';
data[j].bobot = 4 * data[j].sks;

}
else if (data[j].hasil >= 70)
{
data[j].huruf = 'B';
data[j].bobot = 3 * data[j].sks;
}
else if (data[j].hasil >= 56)
{
data[j].huruf = 'C';
data[j].bobot = 2 * data[j].sks;
}
else if (data[j].hasil >= 46)
{
data[j].huruf ='D';
data[j].bobot = 1 * data[j].sks;
}
else
{
data[j].huruf ='E';
data[j].bobot = 0;
}
cout<
}
cout<<"-------------------------STMIK PUTERA BATAM INFORMATIKA----------------------"<
cout<<"==================================================
===========================\n";
cout<<"No Nama Mata Kuliah NILAI \n";
cout<<" ---------------------------------------------------\n";
cout<<" SKS Absen Tugas UTS UAS GRADE BOBOT\n";
cout<<"==================================================
============================\n";
for(j=1;j<=jumlah_mk;j++)
{ cout<<<<<<<<<<<<<<
setw(8)<<<<<<
}
cout<<"==================================================
============================\n";
cout<
{
int i,j;
j=0;
for(i=1;i<=jumlah_mk;i++)
j=j+ data[i].sks;
cout<<"Total SKS : "<<
int a;
double b, c;
b=0;
for(a=1;a<=jumlah_mk;a++)

b=b+ data[a].bobot;
c=b/j;
cout<<"IP : "<<
}}

Sumber :

http://mhsbudidarma.blogspot.com/2012/05/program-sederhana-menghitungip.html
#include <iostream>
using namespace std;
typedef struct
{
int nim;
char matkul[50];
float ip, harkat, sks;
} data;
typedef data ip[101];
int main()
{
ip daftar;
int banyak;
char lagi;
cout<<"copyright 2011 | Hasimhendraharahap"<<endl<<endl;
do {
cout<<"=APLIKASI IPS/IPK="<<endl<<endl;
cout<<"+---------------+"<<endl;
cout<<"|
HARKAT
|"<<endl;
cout<<"+---------------+"<<endl;
cout<<"|
A : 4
|"<<endl;
cout<<"|
A- : 3.75 |"<<endl;
cout<<"|
A/B: 3.5
|"<<endl;
cout<<"|
B+ : 3.25 |"<<endl;
cout<<"|
B : 3
|"<<endl;
cout<<"|
B- : 2.75 |"<<endl;
cout<<"|
B/C: 2.5
|"<<endl;
cout<<"|
C+ : 2.25 |"<<endl;
cout<<"|
C : 2
|"<<endl;
cout<<"|
C- : 1.75 |"<<endl;
cout<<"|
C/D: 1.5
|"<<endl;
cout<<"|
D+ : 1.25 |"<<endl;
cout<<"|
D : 1
|"<<endl;
cout<<"|
D- : 0.75 |"<<endl;
cout<<"|
D/E: 0.5
|"<<endl;
cout<<"|
E+ : 0.25 |"<<endl;
cout<<"|
E : 0
|"<<endl;
cout<<"+---------------+"<<endl;
cout<<endl<<"Banyak Matakuliah : ";
cin>>banyak;
cout<<endl;
float total, sksharkat, totalsks, ips;
total=0;
totalsks=0;
for (int i=1;i<=banyak;i++)
{
cout<<"Matakuliah ke "<<i<<endl;
cout<<"SKS
: ";
cin>>daftar[i].sks;
cout<<"Harkat
: ";
cin>>daftar[i].harkat;
sksharkat=daftar[i].sks*daftar[i].harkat;
total=total+sksharkat;
totalsks=totalsks+daftar[i].sks;
cout<<endl;
}
ips=total/totalsks;
cout<<endl<<"Total SKS
: "<<totalsks<<endl;

cout<<"IP Semester : "<<ips<<endl;


cout<<"Lagi ? [y/n] : ";
cin>>lagi;
}while (lagi!='n');
return 0;

Contoh hasil perhitungan IP Semester