Thursday, 30 November 2023

Program Bayar SKS

 #include<conio.h>

#include<stdio.h>

#include<iostream>

#include<iomanip>

using namespace std;

int main() {

    int n;

    cout << "Masukan Jumlah Mahasiswa: ";cin >> n;

    string namakmps, alamat, website, nama[n],prodi[n],kls[n];

    int nim[n], sks[n], kodeprodi[n],bayar[n],diskon[n],total[n];

   cout << "Masukan Nama Kampus: ";cin >> namakmps;

    cout << "Masukan Alamat: ";cin >> alamat;

    cout << "Masukan Website: ";cin >> website;


    for (int i = 0; i < n; i++)

{

        cout << "Data Ke- " << i + 1 << endl;

        cout << "Nama: ";cin >> nama[i];

        cout << "NIM: ";cin >> nim[i];

        cout << "Prodi: ";cin >> prodi[i];

        cout << "Kelas: ";cin >> kls[i];

        cout << "SKS: ";cin >> sks[i];

        cout << "Kode Prodi: ";cin >> kodeprodi[i];

        cout << endl;

        if (kodeprodi[i] == 11) 

{

            bayar[i] =  sks[i] * 175000;

            diskon[i] =  bayar[i] * 0.2;

        }

else if (kodeprodi[i]==12) 

{

           bayar[i] = sks[i] * 250000;

           diskon[i] = bayar[i] * 0.2;

        }

else if (kodeprodi[i]==13)

  {

            bayar[i] = sks[i] * 150000;

            diskon[i] = bayar[i] * 0.2;

        } 

total[i]= bayar[i]-diskon[i];

    }

    system("cls");

    cout<<"  Nama Kampus : "<<namakmps<<endl;

    cout<<"  Alamat : "<<alamat<<endl;

cout<<"  Website: "<<website<<endl;

cout << "============================================================================================" << endl;

    cout<<"No ";

cout<<"  Nama ";

cout<<"    NIM";

cout<<"    Prodi ";

cout<<"    Kelas";

cout<<"      SKS";

cout<<"      Bayar";

cout<<"        Diskon";

cout<<"         Total " <<endl;

    cout << "============================================================================================" << endl;


    for (int i = 0; i < n; i++) 

{

        cout << setiosflags(ios::left) << setw(4) << i + 1;

        cout << setprecision(2) << " " << setw(5) << nama[i];

        cout << setprecision(2) << "  " << setw(5) << nim[i];

        cout << setprecision(2) << "  " << setw(5) << prodi[i];

        cout << setprecision(2) << "      " << setw(5) << kls[i];

        cout << setprecision(2) << "     " << setw(5) << sks[i];

        cout << setprecision(2) << "   " << setw(5) <<bayar[i];

        cout << setprecision(2) << "       " << setw(5) <<diskon[i];

        cout << setprecision(2) << "        " << total[i]<<endl ;

    }

    cout << "============================================================================================" << endl;

    getch();

}

No comments:

Post a Comment