0% found this document useful (0 votes)
20 views

C++ Listing lthnArrayFngsiClass

The document contains the code for a C++ program that manages ticket sales for a music concert. It includes functions to calculate totals, discounts, taxes, and payment amounts. It defines a class to store ticket data and uses arrays to input multiple tickets. The main function gets input from the user, calls the functions to process each ticket, and outputs a report with the ticket details and total payment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

C++ Listing lthnArrayFngsiClass

The document contains the code for a C++ program that manages ticket sales for a music concert. It includes functions to calculate totals, discounts, taxes, and payment amounts. It defines a class to store ticket data and uses arrays to input multiple tickets. The main function gets input from the user, calls the functions to process each ticket, and outputs a report with the ticket details and total payment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
You are on page 1/ 13

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<iomanip.h>
//fungsi total=harga x jumlah
long total(long a,long b)
{
return(a*b);
}
//fungsi diskon=0,05 x total
long diskon(long c)
{
return(0.05*c);
}
//fungsi pajak=0.01 x total
long pajak(long d)
{
return(0.01*d);
}
//fungsi jumlah bayar=total-disk+ppn
long jumbay(long e,long f,long g)
{
return(e-f+g);
}
//fungsi total bayar=total bayar+jumlah bayar
long tobayar(long h,long i)
{
return(h+i);
}
//pembuatan class dengan nama pesawat
class
{
public:
char kd[5],*nm_band,*hari;
long hrg,ttl,disk,ppn,ttlbyr,jumbel;
}musik[30];
main()
{
char np[20],nk[20],lagi;
long tobay=0;
int jd,i;
awal:
clrscr();
cout<<endl;
gotoxy(7,1);

Tanda # pada baris 1-4 adala

1-4
1
2
3
4
6-29

file-judul I/O standar ya


stdio.h
conio.h
file header yang diguna
iostream.h file header yang dibut
iomanip.h
file header yang dibutuh
fungsi adalah suatu bagian dari progra

38

Fungsi Main adalah suatu fungsi khus

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

cout<<"Program Penjualan Tiket Konser Musik"<<endl;


gotoxy(15,2);
cout<<"KAMUKA AGENCY"<<endl;
gotoxy(10,3);
cout<<"Jl. Rawajati Timur III No. 24"<<endl;
cout<<"\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3
cout<<"Masukan Nama Kasir : ";gets(nk);
cout<<"Masukan Nama Pembeli : ";gets(np);
cout<<"\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3
cout<<"Masukan Jumlah Data : ";cin>>jd;
for(i=1;i<=jd;i++)
{
cout<<"Data ke-"<<i<<endl;
cout<<"Masukan Kode Tiket : ";cin>>musik[i].kd;
if(strcmp(musik[i].kd,"ST")==0||strcmp(musik[i].kd,"st")==0)
{
musik[i].nm_band="ST12";
musik[i].hrg=75000;
musik[i].hari="Rabu";
}
else if(strcmp(musik[i].kd,"UG")==0||strcmp(musik[i].kd,"ug")==0)
{
musik[i].nm_band="Ungu";
musik[i].hrg=100000;
musik[i].hari="Kamis";
}
else if(strcmp(musik[i].kd,"GG")==0||strcmp(musik[i].kd,"gg")==0)
{
musik[i].nm_band="Gigi";
musik[i].hrg=125000;
musik[i].hari="Jumat";
}
else if(strcmp(musik[i].kd,"PD")==0||strcmp(musik[i].kd,"pd")==0)
{
musik[i].nm_band="Padi";
musik[i].hrg=150000;
musik[i].hari="Sabtu";
}
else
{
cout<<"\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3"<<endl;
cout<<"Anda Salah Memasukan Kode !!!!"<<endl;
cout<<"Mau Input Data Lagi [Y|T] : ";cin>>lagi;
if(lagi=='Y'||lagi=='y')
goto awal;
else
goto akhir;

94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140

}
cout<<"Nama Band
: "<<musik[i].nm_band<<endl;
cout<<"Harga
: "<<musik[i].hrg<<endl;
cout<<"Hari Konser
: "<<musik[i].hari<<endl;
cout<<"Jumlah Beli
: ";cin>>musik[i].jumbel;
musik[i].ttl=total(musik[i].hrg,musik[i].jumbel);
if(musik[i].jumbel>5)
musik[i].disk=diskon(musik[i].ttl);
else
musik[i].disk=0;
cout<<"Total Bayar
: "<<musik[i].ttl<<endl;
cout<<"Diskon
: "<<musik[i].disk<<endl;
musik[i].ppn=pajak(musik[i].ttl);
cout<<"PPN
: "<<musik[i].ppn<<endl;
musik[i].ttlbyr=jumbay(musik[i].ttl,musik[i].disk,musik[i].ppn);
cout<<"Jumlah Bayar
: "<<musik[i].ttlbyr<<endl;
tobay=tobayar(tobay,musik[i].ttlbyr);
}
clrscr();
cout<<endl<<endl;
gotoxy(15,3);
cout<<"Program Penjualan Tiket Konser Musik"<<endl;
gotoxy(23,4);
cout<<"KAMUKA AGENCY"<<endl;
gotoxy(18,5);
cout<<"Jl. Rawajati Timur III No. 24"<<endl;
cout<<endl;
cout<<"\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5
cout<<"Nama Kasir : "<<nk;
cout<<"
Nama Pembeli : "<<np<<endl;
cout<<"\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5
cout<<"No Kode Nama Harga Hari Jumlah Total Diskon PPN Jumlah"<<endl;
cout<<" Tiket Band Tiket Konser Beli
Bayar"<<endl;
cout<<"\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5
for(i=1;i<=jd;i++)
{
cout<<setiosflags(ios::left)<<setw(5)<<i;
cout<<setiosflags(ios::left)<<setw(7)<<musik[i].kd;
cout<<setiosflags(ios::left)<<setw(7)<<musik[i].nm_band;
cout<<setiosflags(ios::left)<<setw(7)<<musik[i].hrg;
cout<<setiosflags(ios::left)<<setw(7)<<musik[i].hari;
cout<<setiosflags(ios::left)<<setw(7)<<musik[i].jumbel;
cout<<setiosflags(ios::left)<<setw(10)<<musik[i].ttl;
cout<<setiosflags(ios::left)<<setw(8)<<musik[i].disk;
cout<<setiosflags(ios::left)<<setw(8)<<musik[i].ppn;
cout<<setiosflags(ios::left)<<setw(10)<<musik[i].ttlbyr<<endl;
}

141
142
143
144
145
146
147
148
149
150
151

cout<<"\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5
cout<<"
Total Bayar : Rp. "<<tobay<<endl;
cout<<endl<<endl;
cout<<"Mau Input Data Lagi [Y|T] : ";cin>>lagi;
if(lagi=='Y'||lagi=='y')
goto awal;
else
goto akhir;
getch();
akhir:
}

pada baris 1-4 adalah preprocessor directive . Preprocessor directive adalah perintah perintah yang diberikan kepada compiler untu

file-judul I/O standar yang disediakan oleh C, yang diperlukan untuk program-program yang menggunakan fungsi pustaka I/O standard se
file header yang digunakan supaya program bisa membaca perintah-perintah dari file header conio seperti getch(),clrscr(),gotoxy()

file header yang dibutuhkan untuk kegiatan input dan output dari program. Perintah-perintah yang bisa kita pakai setelah k

file header yang dibutuhkan supaya program bisa melakukan perintah array atau manipulator (pengatur tampilan layar) seperti endl,setio
suatu bagian dari program yang dimaksud untuk mengerjakan suatu tugas tertentu dan letaknya dipisahkan dari bagian program yang me

dalah suatu fungsi khusus yang akan dieksekusi pertama. Setiap program harus mempunyai fungsi main(). Fungsi main() diawali dengan t

\3\3\3\3\3\3\3\3\3\3\3"<<endl;

\3\3\3\3\3\3\3\3\3\3\3"<<endl;

\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5"<<endl;

\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5"<<endl;

\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5"<<endl;

\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5"<<endl;

g diberikan kepada compiler untuk melakukan definisi, memasukkan file library, dll.
kan fungsi pustaka I/O standard seperti pritf(), scanf(), gets()
erti getch(),clrscr(),gotoxy()

h yang bisa kita pakai setelah kita memasang header iostream adalah cout & cin

r tampilan layar) seperti endl,setiosflags,setw


hkan dari bagian program yang menggunakannya

n(). Fungsi main() diawali dengan tanda { (baris 39) yang menyatakan awal dari program dan diakhiri dengan tanda } (baris 151) yang meny

gan tanda } (baris 151) yang menyatakan akhir dari program

You might also like