Contoh Codingan Struct – Programer’s Notepad(Bahasa C++)

Nih wan ada contoh codingan buat fungsi struct 1 semoga bermanfaat ya …

#include
#include
using namespace std;
struct tiket
{
char kode[15];
char dari[20];
char tujuan[20];
float jam;
float harga;
float hasil;
float ppn;
};
int main()
{
cout<<"————————————————————-"<<endl;
cout<<"===================SELAMAT DATANG di Air Asia================"<<endl;
cout<<"————————————————————-"<<endl;
cout<<endl;
tiket tkt;

cout<<"Kode Penerbangan : ";
cin.getline(tkt.kode,15);
cout<<"Dari Bandara : ";
cin.getline(tkt.dari,20);
cout<<"Tujuan Bandara : ";
cin.getline(tkt.tujuan,20);
cout<>tkt.jam,10;
cout<>tkt.harga;
cout<>tkt.ppn;
{
tkt.hasil = tkt.harga*tkt.ppn/100;
tkt.hasil = tkt.harga+tkt.hasil;
}

cout<<endl;
cout<<"————————————————————-"<<endl;
cout<<endl;

cout<<"Kode penerbangan yang anda pilih : "<<tkt.kode<<endl;
cout<<"Dari Bandara yang anda pilih: "<<tkt.dari<<endl;
cout<<"Tujuan Bandara yang anda pilih: "<<tkt.tujuan<<endl;
cout<<"Jam Keberangkatan yang anda pilih: "<<tkt.jam<<" W.I.B"<<endl;
cout<<"Harga Tiket yang anda pilih: "<<"Rp. "<<tkt.harga<<endl;
cout<<"Ppn Penerbangan : "<<tkt.ppn<<"%"<<endl;
cout<<"Akumulasi Harga Tiket: "<<"Rp. "<<tkt.hasil<<endl;

cout<<endl;
cout<<"————————————————————-"<<endl;
cout<<"————————————————————-"<<endl;
system("PAUSE");
return 0;
}

About chandechildz

I'm the simple man Always happy everday every time every well View all posts by chandechildz

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: