Presentasi sedang didownload. Silahkan tunggu

Presentasi sedang didownload. Silahkan tunggu

Jawaban ujian MID. #include int pil; char tny; main(){ menu: cout<<"\nMENU PILIHAN : "; cout<<"\n[1] Hitung IPK Mahasiswa"; cout<<"\n[2] Hitung Gaji Karyawan";

Presentasi serupa


Presentasi berjudul: "Jawaban ujian MID. #include int pil; char tny; main(){ menu: cout<<"\nMENU PILIHAN : "; cout<<"\n[1] Hitung IPK Mahasiswa"; cout<<"\n[2] Hitung Gaji Karyawan";"— Transcript presentasi:

1 Jawaban ujian MID

2 #include int pil; char tny; main(){ menu: cout<<"\nMENU PILIHAN : "; cout<<"\n[1] Hitung IPK Mahasiswa"; cout<<"\n[2] Hitung Gaji Karyawan"; cout<<"\n[3] Keliuar Dari Aplikasi"; cout >pil;

3 switch(pil) {case 1: {int n,sks=0,tsks=0; char mkul[20],ket; float nilai=0,rata,jml=0,ipk=0; cout >n; for(int i=1;i<=n;i++){ cout<<"\n\nData ke = "<<i; cout<<"\n-----------------\n"; cout<<"Mata kuliah = " ;gets(mkul); cout >sks; cout >ket; if(ket=='A'|| ket=='a') nilai+=(4*sks); else if(ket=='B' || ket=='b') nilai+=(3*sks); else if(ket=='C' || ket=='c')

4 nilai+=(2*sks); else if(ket=='D' || ket=='d') nilai+=(1*sks); else if(ket=='E' || ket=='e') nilai+=(0*sks); else cout<<"Range nilai hanya dari A-E"; tsks+=sks; ipk=nilai/tsks; } cout<<"\nNilai total = "<<nilai; cout<<"\nTotal SKS = "<<tsks; cout<<"\nIPK = “<<setiosflags(ios::fixed) <<setprecision(2)<<ipk; cout<<"\n\n\nAnda ingin kembali ke Menu utama ?"; cout >tny; if(tny=='y' ||tny=='Y') {clrscr(); goto menu;}}

5 case 2: {char nama_karyawan[20],nik[5],gol; float gator,pajak,gaber,gapok,tunj,makan,trans; bool status,kelamin,kendaraan; cout<<"\n*************************************"; cout<<"\n* MENGHITUNG GAJI BERSIH KARYAWAN *"; cout<<"\n*************************************"; cout<<endl<<endl; cout<<"Input nama karyawan : ";gets(nama_karyawan); cout >nik; cout >kelamin; cout >status; cout >kendaraan; cout >gol; cout >makan; if (gol=='a' || gol=='A') gapok=500; else if (gol=='b' || gol=='B')

6 gapok=600; else if (gol=='a' || gol=='A') gapok=700; cout<<"\nGaji pokok anda : Rp "<<gapok; if(kelamin==1 && status==1) tunj=500; else tunj=0; cout<<"\nTunjangan anda : Rp "<<tunj; if(kendaraan==1) trans=1000; else if(kendaraan==0) trans=500; else trans=0; cout<<"\nTransport anda/bln : Rp "<<trans; gator=gapok+tunj+makan+trans; pajak=gator*0.05;

7 gaber=gator-pajak; cout<<"\nGaji kotornya : Rp "<<gator; cout<<"\nPotongan pajak anda : Rp "<<pajak; cout<<endl<<endl; cout<<"\nGaji bersih adalah : Rp “ <<setiosflags(ios::fixed)<<setprecision(2) <<gaber; cout<<"\n\n\nAnda ingin kembali ke Menu utama ?"; cout >tny; if(tny=='y' ||tny=='Y') {clrscr(); goto menu;} } default: return 0;} getch();}


Download ppt "Jawaban ujian MID. #include int pil; char tny; main(){ menu: cout<<"\nMENU PILIHAN : "; cout<<"\n[1] Hitung IPK Mahasiswa"; cout<<"\n[2] Hitung Gaji Karyawan";"

Presentasi serupa


Iklan oleh Google