Pemanfaatan KBHIT()

usahawan-maju

  Kombinasi pendeteksi penekanan tombol keyboard (kbhit())


#include<iostream.h>
  #include<stdio.h>
 #include<conio.h>
 #include<iomanip.h>

 void main()
 {  double gaji_pokok, tunjangan, pph, total_gaji_bersih;
      char nip[15],nama1[30], lanjut1;
      cout<<setprecision(12);

cout<<"NIP               :";
 cin>>nip;
cout<<"NAMA              :";
 cin>>nama1;
cout<<"GAJI POKOK        : Rp.";
 cin>>gaji_pokok;
     tunjangan=0.15*gaji_pokok;
     pph=0.1*(gaji_pokok+tunjangan);
      total_gaji_bersih=(gaji_pokok+tunjangan)-pph;
cout<<"TUNJANGAN         :"<<"Rp."<<tunjangan<<endl;
cout<<"PPH               :"<<"Rp."<<pph<<endl;
cout<<"TOTAL GAJI BERSIH :"<<"Rp."<<total_gaji_bersih;
     gotoxy(12,15);printf(" Tekan Enter untuk Soal ke-dua!!!");
     scanf("%c",&lanjut1);

                 if (kbhit())lanjut1=getch(); //posisi kbhit()
                 clrscr();

//soal ke-dua


                char nim[20], nama2[30], lanjut,lanjut0;
    double nilai_tugas, nilai_quis, nilai_uts, nilai_uas, total_nilai;
        cout<<setprecision(12);

    gotoxy(15,1);cout<< "Soal ke-dua";
gotoxy(3,3);cout<<"NIM";gotoxy(15,3);cout<<":";
cin>>nim;
gotoxy(3,4);cout<<"NAMA"; gotoxy(15,4);cout<<":";
cin>>nama2;
gotoxy(3,5);cout<<"NILAI TUGAS"; gotoxy(15,5);cout<<":";
cin>>nilai_tugas;
gotoxy(3,6);cout<<"NILAI QUIS"; gotoxy(15,6);cout<<":";
cin>>nilai_quis;
gotoxy(3,7);cout<<"NILAI UTS";  gotoxy(15,7);cout<<":";
cin>>nilai_uts;
gotoxy(3,8);cout<<"NILAI UAS"; gotoxy(15,8);cout<<":";
cin>>nilai_uas;

total_nilai=(0.2*nilai_tugas)+(0.15*nilai_quis)+(0.3*nilai_uts)+(0.35*nilai_uas);
gotoxy(3,9);cout<<"TOTAL NILAI";gotoxy(15,9);cout<<":"<<total_nilai;

          gotoxy(12,15);printf(" Tekan Enter untuk Soal ke-tiga!!!");
     scanf("%c",&lanjut);

                 if (kbhit())lanjut=getch();  //posisi kbhit()
                 clrscr();

    // Soal ke-tiga

        char id[10], nama_barang1[30],nama_barang2[30],disc2[5];
double jumlah1, jumlah2, disc1;
double harga1, harga2, ppn, total_pembelian, total_beli1, total_beli2;
   cout<<setprecision(12);

    gotoxy(15,1);cout<< "Soal ke-tiga";
gotoxy(3,3);cout<<"ID CUST";gotoxy(20,3);cout<<":";
cin>>id;
gotoxy(3,4);cout<<"BARANG YANG DIBELI"; gotoxy(20,4);cout<<":";
gotoxy(3,5);cout<<"NAMA BARANG"; gotoxy(20,5);cout<<":";
cin>>nama_barang1;
gotoxy(3,6);cout<<"JUMLAH";gotoxy(25,6);cout<<"KARDUS";gotoxy(20,6);cout<<":";
cin>>jumlah1;
gotoxy(3,7);cout<<"HARGA";  gotoxy(20,7);cout<<":"<<"Rp.";
cin>>harga1;
gotoxy(3,8);cout<<"DISC"; gotoxy(24,8);cout<<"%"; gotoxy(20,8);cout<<":";
cin>>disc1;
gotoxy(3,9);cout<<"NAMA BARANG";  gotoxy(20,9);cout<<":";
cin>>nama_barang2;
gotoxy(3,10);cout<<"JUMLAH";  gotoxy(20,10);cout<<":";
cin>>jumlah2;
gotoxy(3,11);cout<<"HARGA";  gotoxy(20,11);cout<<":"<<"Rp.";
cin>>harga2;
gotoxy(3,12);cout<<"DISC";  gotoxy(20,12);cout<<":";
cin>>disc2;
total_beli1=(disc1/100)*(jumlah1*harga1);
total_beli2= jumlah2*harga2;
ppn=0.1*(total_beli1+total_beli2);
total_pembelian=(total_beli1+total_beli2)-ppn;
gotoxy(1,13);cout<<"PPN";  gotoxy(20,13);cout<<":"<<ppn;
gotoxy(1,14);cout<<"TOTAL PEMBELIAN";  gotoxy(20,14);cout<<":"<<total_pembelian;


gotoxy(25,17);cout<<"SELESAI.......";

getch();
}

domain gratis http://www.000webhost.com/685133.html 


usahawan-maju
Pemanfaatan KBHIT() | 5