Senin, 05 Desember 2016

contoh structure array function

#include <conio.h>
#include <iostream.h>
#include <iomanip.h>
#include <stdio.h>
garis()
{
cout<<"==============================================="<<endl;
}

main()
{
int data,j,grand=0,totaljum=0,tobay,diskon;
char input;
struct
{
char kode,nama[30];
int harga,jumbel,total;
}kereta[5];

a:
clrscr();
garis();
cout<<" Daftar Penjualan Tiket "<<endl;
cout<<"Masukan Banyak Data";cin>>data;

for(j=1;j<=data;j++)
{
cout<<"Data Ke. "<<j<<endl;
cout<<"Kode Kereta [1/2/3] : ";cin>>kereta[j].kode;

if (kereta[j].kode=='1')
{
strcpy(kereta[j].nama,"Argo Bromo");
kereta[j].harga=250000;
}

else if (kereta[j].kode=='2')
{
strcpy(kereta[j].nama,"Argo Lawu");
kereta[j].harga=300000;
}

else if (kereta[j].kode=='3')
{
strcpy(kereta[j].nama,"Pangandaran");
kereta[j].harga=200000;
}

else
{
strcpy(kereta[j].nama,"Tidak Ada Kereta");
kereta[j].harga=0;
}
cout<<"Nama Kereta : "<<kereta[j].nama<<endl;
cout<<"Harga    : "<<kereta[j].harga<<endl;
cout<<"Jumlah Beli : ";cin>>kereta[j].jumbel;

kereta[j].total=kereta[j].jumbel*kereta[j].harga;
cout<<"Total Pembayaran : "<<kereta[j].total<<endl;
cout<<endl;
}
clrscr();
garis();
cout<<"Daftar Penjualan tiket"<<endl;
garis();
cout<<"No    Kode    Nama            Harga        Jumlah Total"<<endl;
cout<<"        Tiket    Kereta        Tiket        Beli     Harga"<<endl;
garis();

for(j=1;j<=data;j++)
{
cout<<setiosflags(ios::left)<<setw(5)<<j;
cout<<setiosflags(ios::left)<<setw(7)<<kereta[j].kode;
cout<<setiosflags(ios::left)<<setw(15)<<kereta[j].nama;
cout<<setiosflags(ios::left)<<setw(8)<<kereta[j].harga;
cout<<setiosflags(ios::left)<<setw(8)<<kereta[j].jumbel;
cout<<setiosflags(ios::left)<<setw(9)<<kereta[j].total<<endl;
grand=grand+kereta[j].total;
totaljum=totaljum+kereta[j].jumbel;
}
garis();
cout<<"Grand Total            : "<<grand<<endl;
cout<<"Total Jumlah Beli    : "<<totaljum<<endl;
if(totaljum>=5)
    diskon=grand*10/100;
else
   diskon=0;
cout<<"Diskon                         : "<<diskon<<endl;
garis();
tobay=grand-diskon;
cout<<"Total Bayar Keseluruhan :  "<<tobay<<endl;
garis();
cout<<"Input Data Lagi ? [Y/N] : ";cin>>input;
if(input=='y' || input=='Y')
goto a;
getch();
}

fungsi protokol (POP3,FTP,ICMP,ARP,SMTP),dan kelebihan,kekurangan dari ipv4,ipv6

Fungsi protokol (POP3,FTP,ICMP,ARP,SMTP), dan kelebihan,kekurangan dari IPV4,IPV6 POP3   (Post Office Protocol version 3)  ...