titel.

WIZZEND CErEATION (BAYU WISNAWA) STIKOM BALI ALWAYS THE FIRTS

Wizzend Creation

Nama lengkap: I Putu Gede Bayu Wisnawa (Wizzend) Alamat : Jl.Seroja no 40 Denpasar,Tonja,Br SENGGUAN. Hobi : Futsal dengan teman-teman!! (HARAT F.C) HP : 081916548404 JANGAN LUPA ADD MY FACEBOOK (www.wizzend@yahoo.com)

Minggu, 22 Mei 2011

Latihan C++ Class, Class Array, Struct, Struc Array
Akademi Manajemen Informatika dan Komputer Bina Sarana Informatika
1
Latihan Class Biasa
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
class pesawat
{
public:
char nama[30],*napes;
int beli,kode,harga;
long int jumlah,total,ppn,diskon;
};
main()
{
clrscr();
pesawat tiket;
cout<<" Travel AL-Mukti"<<endl;
cout<<"=============================================="<<endl;
cout<<"Nama Penumpang :";gets(tiket.nama);
cout<<"Kode Pesawat [1/2/3/4]:";cin>>tiket.kode;
cout<<"Jumlah Tiket :";cin>>tiket.beli;
if(tiket.kode==1)
{tiket.napes="Lion Air";
tiket.harga=200000;
}
else
if(tiket.kode==2)
{tiket.napes="Adam Air";
tiket.harga=300000;
}
else
if(tiket.kode==3)
{tiket.napes="Star Air";
tiket.harga=350000;
}
else
{tiket.napes="Batavia Air";
tiket.harga=255000;
}
cout<<"Nama Pesawat :"<<tiket.napes<<endl;
cout<<"Harga Tiket :"<<tiket.harga<<endl;
tiket.jumlah=tiket.harga*tiket.beli;
cout<<"Jumlah Bayar :"<<tiket.jumlah<<endl;
if (tiket.beli>5)
tiket.diskon=tiket.jumlah*5/100;
else
LAB D SORE ESH/DONI
Latihan C++ Class, Class Array, Struct, Struc Array
Akademi Manajemen Informatika dan Komputer Bina Sarana Informatika
2
tiket.diskon=0;
cout<<"Diskon :"<<tiket.diskon<<endl;
tiket.ppn=tiket.jumlah*10/100;
cout<<"PPN :"<<tiket.ppn<<endl;
tiket.total=tiket.jumlah-tiket.diskon+tiket.ppn;
cout<<"Total bayar :"<<tiket.total<<endl;
getch();
}
Layout Class Biasa
LAB D SORE ESH/DONI
Latihan C++ Class, Class Array, Struct, Struc Array
Akademi Manajemen Informatika dan Komputer Bina Sarana Informatika
3
Latihan Ke 1 Class Array
DAFTAR GAJI PEGAWAI
PT.MAKMUR
``````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````
Input Jumlah Karyawan :
Data Karyawan Ke 1
NIP :
Nama Pegawai :
Golongan :
Jabatan :
Gaji Pokok :
Tunjangan Jabatan :
REKAPITULASI DAFTAR GAJI PEGAWAI
PT. MAKMUR
``````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````
NIP NAMA GOLONGAN JABATAN GAJI TUNJANGAN PPH GAJI
PEGAWAI POKOK JABATAN BERSIH
``````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````
``````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````
JUMLAH SELURUH GAJI :Rp.
Ketentuan Soal :
Golongan Jabatan Gaji Pokok Tunjangan Jabatan
1 Tetap 3000000 10% dari Gaji Pokok
2 Honorer 2500000 Tidak dapat tunjangan
PPH = 10% dari Gaji Pokok
Gaji Bersih =Gaji Pokok+Tunjangan Jabatan-PPH
LAB D SORE ESH/DONI
Latihan C++ Class, Class Array, Struct, Struc Array
Akademi Manajemen Informatika dan Komputer Bina Sarana Informatika
4
Listing Program:
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<iomanip.h>
class gaji
{
public:
char nip[10],nama[20],*jab;
long int jum_total,gapok,tunjab,pph,gaji_bersih;
int gol;
};
main()
{
int i,j;
float jum_total;
gaji pegawai[10];
cout<<" DAFTAR GAJI PEGAWAI "<<endl;
cout<<" PT. MAKMUR "<<endl;
cout<<"========================================="<<endl;
cout<<"input jumlah pegawai :";cin>>j;
for (i=1;i<=j;i++)
{
cout<<"data pegawai ke-"<<i<<endl;
cout<<"NIP :";cin>>pegawai[i].nip;
cout<<"NAMA :";gets(pegawai[i].nama);
cout<<"Gol [1/2] :";cin>>pegawai[i].gol;
if(pegawai[i].gol==1)
{pegawai[i].jab="Tetap";
pegawai[i].gapok=3000000;
pegawai[i].tunjab=pegawai[i].gapok*10/100;
}
else
{pegawai[i].jab="Honorer";
pegawai[i].gapok=2500000;
pegawai[i].tunjab=0;
}
cout<<"Jabatan :"<<pegawai[i].jab<<endl;
cout<<"Gaji Pokok :"<<pegawai[i].gapok<<endl;
cout<<"Tunjangan jabatan :"<<pegawai[i].tunjab<<endl<<endl;
}
clrscr();
cout<<" REKAPITULASI DAFTAR GAJI PEGAWAI "<<endl;
cout<<" PT. MAKMUR "<<endl;
LAB D SORE ESH/DONI
Latihan C++ Class, Class Array, Struct, Struc Array
Akademi Manajemen Informatika dan Komputer Bina Sarana Informatika
5
cout<<"================================================================="<<endl;
cout<<"NIP Nama Golongan Jabatan Gaji Tunjangan PPH Gaji "<<endl;
cout<<" Pegawai Pokok Jabatan Bersih"<<endl;
cout<<"================================================================="<<endl;
for(i=1;i<=j;i++)
{
cout<<setiosflags(ios::left)<<setw(12)<<pegawai[i].nip;
cout<<setiosflags(ios::left)<<setw(14)<<pegawai[i].nama;
cout<<setiosflags(ios::left)<<setw(8)<<pegawai[i].gol;
cout<<setiosflags(ios::left)<<setw(8)<<pegawai[i].jab;
cout<<setiosflags(ios::right)<<setw(10)<<pegawai[i].gapok;
cout<<setiosflags(ios::right)<<setw(9)<<pegawai[i].tunjab;
pegawai[i].pph=pegawai[i].gapok*10/100;
cout<<setiosflags(ios::right)<<setw(8)<<pegawai[i].pph;
pegawai[i].gaji_bersih=pegawai[i].gapok+pegawai[i].gapok-pegawai[i].pph;
cout<<setiosflags(ios::right)<<setw(10)<<pegawai[i].gaji_bersih<<endl;
jum_total=jum_total+pegawai[i].gaji_bersih;
}
cout<<"================================================================"<<endl;
cout<<" Jumlah Seluruh Gaji :Rp."<<setprecision(10)<<jum_total<<endl;
getch();
}
Layout Ke 1 Class Array
LAB D SORE ESH/DONI
Latihan C++ Class, Class Array, Struct, Struc Array
Akademi Manajemen Informatika dan Komputer Bina Sarana Informatika
6
Latihan Ke 2 Class Array
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<iomanip.h>
class penginapan
{
public:
char kode[5],*nama[5];
int harga[5],lama[5];
long int bayar[5];
};
main()
{
char lagi;
float total;
int i,j;
penginapan hotel;
awal:
clrscr();
cout<<" PENGINAPAN HOTEL HANDA YANNA "<<endl;
cout<<"=================================================================="<<endl
;
cout<<"Masukan jumlah data =";cin>>j;
for (i=1;i<=j;i++)
{
cout<<"data penyewa ke- :"<<i<<endl;
cout<<"masukan kode kamar :";cin>>hotel.kode[i];
if (hotel.kode[i]=='A'||hotel.kode[i]=='a')
{hotel.nama[i]="Angel";
hotel.harga[i]=500000;
LAB D SORE ESH/DONI
Latihan C++ Class, Class Array, Struct, Struc Array
Akademi Manajemen Informatika dan Komputer Bina Sarana Informatika
7
}
else if (hotel.kode[i]=='B'||hotel.kode[i]=='b')
{hotel.nama[i]="Bunga";
hotel.harga[i]=255000;
}
else
{hotel.nama[i]="Cantik";
hotel.harga[i]=350000;
}
cout<<"nama kamar :"<<hotel.nama[i]<<endl;
cout<<"harga :"<<hotel.harga[i]<<endl;
cout<<"masukan lama sewa :";cin>>hotel.lama[i];
hotel.bayar[i]=hotel.lama[i]*hotel.harga[i];
cout<<"total bayar :"<<hotel.bayar[i]<<endl;
cout<<endl;
}
cout<<endl<<endl;
clrscr();
cout<<" PENGINAPAN HOTEL HANDA YANNA "<<endl;
cout<<"=================================================================="<<endl
;
cout<<"no. kode nama harga lama biaya "<<endl;
cout<<" kamar kamar sewa "<<endl;
cout<<"=================================================================="<<endl
;
for (i=1;i<=j;i++)
{
cout<<setiosflags(ios::left)<<setw(5)<<i;
cout<<setiosflags(ios::left)<<setw(10)<<hotel.kode[i];
cout<<setiosflags(ios::left)<<setw(10)<<hotel.nama[i];
cout<<setiosflags(ios::right)<<setprecision(8)<<setw(12)<<hotel.harga[i];
cout<<setiosflags(ios::right)<<setprecision(2)<<setw(10)<<hotel.lama[i];
cout<<setiosflags(ios::right)<<setprecision(8)<<setw(10)<<hotel.bayar[i]<<endl;
total=total+hotel.bayar[i];
}
cout<<"=================================================================="<<endl
;
cout<<"total = Rp"<<setprecision(10)<<total<<endl<<endl;
cout<<"Mau Isi Data Lagi?[Y/T]";cin>>lagi;
if(lagi=='Y'||lagi=='y')
goto awal;
else
goto akhir;
akhir:
getch();
}
LAB D SORE ESH/DONI
Latihan C++ Class, Class Array, Struct, Struc Array
Akademi Manajemen Informatika dan Komputer Bina Sarana Informatika
8
Layout Ke 2 Class Array
LAB D SORE ESH/DONI
Latihan C++ Class, Class Array, Struct, Struc Array
Akademi Manajemen Informatika dan Komputer Bina Sarana Informatika
9
Latihan Struct Biasa
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
main()
{
struct
{
char nim[10],nama[20];
float nilai;
}
mahasiswa;
clrscr();
cout<<"masukan NIM :";cin>>mahasiswa.nim;
cout<<"masukan Nama :";gets(mahasiswa.nama);
cout<<"masukan Nilai:";cin>>mahasiswa.nilai;
clrscr();
cout<<"NIM :"<<mahasiswa.nim<<endl;
cout<<"Nama :"<<mahasiswa.nama<<endl;
cout<<"Nilai :"<<mahasiswa.nilai<<endl;
getch();
}
Layout Struct Biasa
LAB D SORE ESH/DONI
Latihan C++ Class, Class Array, Struct, Struc Array
Akademi Manajemen Informatika dan Komputer Bina Sarana Informatika
10
Latihan Struct Array
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<iomanip.h>
main()
{
int i,j;
const upah=40000;
char bulan[25],lagi;
float total_jam,total_lem;
struct
{
char nik[9],nama[25];
int jml_jam;
float upah_lem,total_gaji;
}
pegawai[5];
clrscr();
cout<<"masukkan jumlah data :";cin>>j;
for (i=1;i<=j;i++)
{
awal:
clrscr();
cout<<"data pegawai ke- :"<<i<<endl;
cout<<"NIK karyawan :";cin>>pegawai[i].nik;
cout<<"Nama karyawan :";gets(pegawai[i].nama);
cout<<"jumlah jam lembur :";cin>>pegawai[i].jml_jam;
cout<<endl;
}
clrscr();
cout<<" DAFTAR LEMBUR KARYAWAN "<<endl;
cout<<endl;
cout<<"Bulan = ";cin>>bulan;
cout<<"===================================================================="<<e
ndl;
cout<<"No. NIK Nama Upah jumlah total gaji "<<endl;
cout<<" lembur jam lembur "<<endl;
cout<<"====================================================================="<<
endl;
for (i=1;i<=j;i++)
{
cout<<setiosflags(ios::left)<<setw(5)<<i;
cout<<setiosflags(ios::left)<<setw(10)<<pegawai[i].nik;
LAB D SORE ESH/DONI
Latihan C++ Class, Class Array, Struct, Struc Array
Akademi Manajemen Informatika dan Komputer Bina Sarana Informatika
11
cout<<setiosflags(ios::left)<<setw(15)<<pegawai[i].nama;
cout<<setiosflags(ios::left)<<setw(15)<<upah;
cout<<setiosflags(ios::left)<<setw(15)<<setprecision(2)<<pegawai[i].jml_jam;
pegawai[i].total_gaji=pegawai[i].jml_jam*upah;
cout<<setiosflags(ios::left)<<setw(15)<<setprecision(8)<<pegawai[i].total_gaji<<endl;
total_jam=total_jam+pegawai[i].jml_jam;
total_lem=total_lem+pegawai[i].total_gaji;
}
cout<<"=================================================================="<<endl
;
cout<< "total upah/lembur : "<<total_jam<<" "<<"RP."<<total_lem<<endl;
cout<<endl;
cout<<"mau tambah lagi ? [Y/T] :";cin>>lagi;
if (lagi=='Y'||lagi=='y')
goto awal;
else
goto akhir;
akhir:
getch();
}
Layout Struct Array
LAB D SORE ESH/DONI
Latihan C++ Class, Class Array, Struct, Struc Array

Stikom bali informatika

0 komentar :

Posting Komentar