Struck Dalam Array

#include <conio.h>
#include <iostream.h>
#include <stdio.h>
#include <iomanip.h>
hargakoran(char kode,char **nm,float *hrg)
{
switch (kode)
{
case ‘M’:
case ‘m’:
{
*nm=”Media Indonesia”;
*hrg=2500;}
break;
case ‘R’:
case ‘r’:
{
*nm=”Republika”;
*hrg=2000;}
break;
case ‘S’:
case ‘s’:
{
*nm=”Sindo”;
*hrg=3000;}
break;}}
main()
{
int i,J;
struct
{
char nama[10],kd,*koran;
float hrg,ambil,kembali,terjual,total;
}
pengecer[10];
clrscr();
cout<<”    AGEN KORAN SINAR BUMI”<<endl;
cout<<“===================================”<<endl;
cout<<“Banyak Pengecer    :”;cin>>J;
cout<<endl;
for (i=1;i<=J;i++)
{
cout<<“Data Pengecer ke- :”<<i<<endl;
cout<<“Kode Koran [M/R/S]:”;cin>>pengecer[i].kd;
cout<<“Nama Pengecer       :”;cin>>pengecer[i].nama;
hargakoran(pengecer[i].kd,&pengecer[i].koran,&pengecer[i].hrg);
cout<<“Nama Koran      :”<<pengecer[i].koran<<endl;
cout<<“Harga          :”<<pengecer[i].hrg<<endl;
cout<<“Jumlah Ambil       :”;cin>>pengecer[i].ambil;
cout<<“Jumlah Kembali       :”;cin>>pengecer[i].kembali;
cout<<endl;
pengecer[i].total=(pengecer[i].ambil-pengecer[i].kembali)*pengecer[i].hrg;
}
clrscr();
cout<<“AGEN KORAN SINAR BUMI”<<endl;
cout<<“==============================”<<endl;
cout<<“banyak pengecer  :”;cin>>J;
cout<<endl;
for (i=1;i<=J;i++)
{
cout<<“Data Pengecer ke-  :”<<i<<endl;
cout<<“Kode Koran [M/R/S] :”;cin>>pengecer[i].kd;
cout<<“Nama pengecer      :”;cin>>pengecer[i].nama;
hargakoran(pengecer[i].kd,&pengecer[i].koran,&pengecer[i].hrg);
cout<<“Nama koran         :”<<pengecer[i].koran<<endl;
cout<<“harga              :”<<pengecer[i].hrg<<endl;
cout<<“jumlah ambil       :”;cin>>pengecer[i].ambil;
cout<<“jumlah kembali     :”;cin>>pengecer[i].kembali;
cout<<endl;
pengecer[i].total=(pengecer[i].ambil-pengecer[i].kembali)*pengecer[i].hrg;
}
clrscr();
cout<<“=====================================================================”<<endl;
cout<<”             AGEN KORAN SINAR BUMI”<<endl;
cout<<“———————————————————————“<<endl;
cout<<“No.     Nama      Nama      Jumlah       Jumlah     Harga      Total”<<endl;
cout<<”  Pengecer   Koran     Ambil     Kembali     Koran    Penjualan”<<endl;
cout<<“===============================================================”<<endl;
for(i=1;i<=J;i++)
{
cout<<setiosflags(ios::left)<<setw(8)<<i;
cout<<setiosflags(ios::left)<<setw(11)<<pengecer[i].nama;
cout<<setiosflags(ios::left)<<setw(17)<<pengecer[i].koran;
cout<<setiosflags(ios::left)<<setw(13)<<pengecer[i].ambil;
cout<<setiosflags(ios::left)<<setw(10)<<pengecer[i].kembali;
cout<<setiosflags(ios::left)<<setw(10)<<pengecer[i].hrg;
cout<<setiosflags(ios::left)<<setw(6)<<pengecer[i].total;
cout<<endl;
}
cout<<“===============================================================”<<endl;
getch();
}

 

 

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: