Minggu, 08 Mei 2011

Belajar C++ Program Hitung Gaji Pegawai



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



struct
{
char nip[9];
char nama[25];
int kode_gol;
float gaji_pokok;
float tunjangan;
float gaji_bersih;
} pgw;
char jwb;
main()
{
lagi :
clrscr();

 cout <<"Masukan NIP          : "; cin >> pgw.nip;
 cout <<"Masukan Nama         : "; cin >> pgw.nama;
 cout <<"Masukan Kode Golongan: "; cin >> pgw.kode_gol;

 switch (pgw.kode_gol)
 {
 case 1:
 {
 pgw.gaji_pokok=600000;break;}
 case 2:
 {
 pgw.gaji_pokok=700000;break;}
 case 3:
 {
 pgw.gaji_pokok=800000;break;}
 default :
{
 pgw.gaji_pokok=900000;break;}}

 pgw.tunjangan = ((pgw.gaji_pokok * 10)/100);
 pgw.gaji_bersih = pgw.gaji_pokok + pgw.tunjangan;

 //tampilkan output sesuai dengan ketentuan
 cout <<endl <<endl;
 cout <<"NIP           : " << pgw.nip << endl;
 cout <<"NAMA Pengawai : " << pgw.nama << endl;
 cout <<"Golongan      : " << pgw.kode_gol << endl;
 cout <<"Gaji Pokok    : " << pgw.gaji_pokok << endl;
 cout <<"Tunjangan     : " << pgw.tunjangan << endl;
 cout <<"Gaji Bersih   : " << pgw.gaji_bersih << endl;
 cout <<endl;
 cout <<"Coba Lagi [Y/T] ? ";cin>>jwb;
 if (jwb=='Y' || jwb=='T')
 goto lagi;
 getch();
 }

Tidak ada komentar:

Posting Komentar

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More