70 likes | 196 Views
Jawaban ujian MID. #include<iostream.h> #include<conio.h> #include<iomanip.h> #include<stdio.h> int pil; char tny; main(){ menu: cout<<"<br>MENU PILIHAN : "; cout<<"<br>[1] Hitung IPK Mahasiswa"; cout<<"<br>[2] Hitung Gaji Karyawan"; cout<<"<br>[3] Keliuar Dari Aplikasi";
E N D
#include<iostream.h> #include<conio.h> #include<iomanip.h> #include<stdio.h> 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<<"\n\nInput pilihan anda : ";cin>>pil;
switch(pil) {case 1: {int n,sks=0,tsks=0; char mkul[20],ket; float nilai=0,rata,jml=0,ipk=0; cout<<"Input banyak mata kuliah =;cin>>n; for(int i=1;i<=n;i++){ cout<<"\n\nData ke = "<<i; cout<<"\n-----------------\n"; cout<<"Mata kuliah = " ;gets(mkul); cout<<"Jumlah SKS = ";cin>>sks; cout<<"Nilai huruf = ";cin>>ket; if(ket=='A'|| ket=='a') nilai+=(4*sks); else if(ket=='B' || ket=='b') nilai+=(3*sks); else if(ket=='C' || ket=='c')
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<<"\nJawab dengan 'Y' atau 'T' ";cin>>tny; if(tny=='y' ||tny=='Y') {clrscr(); goto menu;}}
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<<"Input NIK : ";cin>>nik; cout<<"Jns kelamin[0=P,1=L]: ";cin>>kelamin; cout<<"Status[0=S,1=Nikah] : ";cin>>status; cout<<"Transport[0=S,1=Mbi]: ";cin>>kendaraan; cout<<"Golongan[A,B,C] : ";cin>>gol; cout<<"Input uang makan : Rp ";cin>>makan; if (gol=='a' || gol=='A') gapok=500; else if (gol=='b' || gol=='B')
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;
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<<"\nJawab dengan 'Y' atau 'T' ";cin>>tny; if(tny=='y' ||tny=='Y') {clrscr(); goto menu;} } default: return 0;} getch();}