Contoh program C++ Perulangan, Menghitung SKS, Bobot, Nilai dan IPK - TeachMeSoft

Contoh program C++ Perulangan, Menghitung SKS, Bobot, Nilai dan IPK

Contoh program C++ Perulangan, Menghitung SKS, Bobot, Nilai dan IPK


 Source code


#include<iostream>
using namespace std;

main(){
    int sks[10],bot[10],d,a, tot=0,totbot=0,totnilai=0,totnilai2=0;  // deklarasi variabel
    float ipk;
    char mk[20][10];// [20] karakter dan 10 data
        cout<<"--------------------------------------"<<endl;
        cout<<"Masukan batas perulangan akhir: ";cin>>a;
        cout<<"--------------------------------------"<<endl;
        for(int i=0; i<a; i++){
            cout<<" 1. Masukan nama MK              : "; cin>>mk[i];
            cout<<" 2. Masukan SKS MK               : "; cin>>sks[i];
            cout<<" 3. Masukan bobot nilai MK (0-4) : "; cin>>bot[i];
            cout<<endl<<endl;
            totbot+=bot[i];
            tot+=sks[i];
            totnilai=sks[i]*bot[i];
            totnilai2+=totnilai;
        }
        ipk=(float)totnilai2/tot;
        cout<<"no. MK / SKS / bobot"<<endl;
        for(int i=0; i<a; i++){
            cout<<i<<". "<<mk[i]<<" / "<<sks[i]<<" / "<<bot[i]<<endl;
        }
        cout<<"Total SKS   : "<<tot<<endl;
        cout<<"Total bobot : "<<totbot<<endl;
        cout<<"IPK         :  "<<ipk<<endl;
       cout<<"Total nilai : "<<totnilai2<<endl;
}


 Output








Disqus comments