Jumat, 11 Mei 2012

Program C++ Menghitung IPK (FOR)


Menghitung IPK (FOR)


#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <iomanip.h>
int main()
{
                int jml_matakul, i, sks[15], total_nil[15];
                float jml_total_nil=0, total_sks=0, ipk;
                char namakul[15][15], nil_huruf[15];
                cout<<"\nJumlah Mata Kuliah  : "; cin>>jml_matakul;
                for(i=1;i<=jml_matakul;i++)
                {
                                cout<<"\n\nMasukkan Nilai Mata Kuliah "<<i<<"     : "; cin>>namakul[i];
                                cout<<"Masukkan Nilai Huruf a-e           : "; cin>>nil_huruf[i];
                                cout<<"Masukkan Jumlah SKS                 : "; cin>>sks[i];
                if(nil_huruf[i]=='a')
                                total_nil[i]=4*sks[i];
                else if(nil_huruf[i]=='b')
                                total_nil[i]=3*sks[i];
                else if(nil_huruf[i]=='c')
                                total_nil[i]=2*sks[i];
                else if(nil_huruf[i]=='d')
                                total_nil[i]=1*sks[i];

                 jml_total_nil += total_nil[i];
                 total_sks += sks[i];
                }
                ipk=jml_total_nil/total_sks;
                cout<<"\nJumlah SKS  : "<<total_sks;
                cout<<"\nIPK Anda    : "<<setprecision(2)<<ipk;
                getch();
}



0 komentar:

Posting Komentar