Cara Menampilkan Tabel di C++

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<iomanip.h>
#include<string.h>

main()
{
int n,i,bb[10],hrg[10],jml_byr;

float jml[10],pjk,tbl;

char jns[10][10],awal,jp;

awal:
clrscr();

puts(“Gerobak fried chicken”);
puts(“________________________”);
puts(“Kode    Jenis     Harga”);
puts(“________________________”);
puts(” D      Dada      Rp2500″);
puts(” P      Paha      Rp2000″);
puts(” S      Sayap     Rp1500″);
puts(“________________________”);
puts(” “);
cout<<“banyak jenis :”;cin>>n;
cout<<endl;
for(i=1;i<=n;i++)
{
cout<<“Jenis ke-“<<i<<endl;
cout<<“Jenis potong[D/P/S]:”;cin>>jp;cout<<endl;
switch (jp)
{
case’D’:
case’d’:
strcpy(jns[i],”Dada”);
hrg[i]=2500;
break;
case’P’:
case’p’:
strcpy(jns[i],”Paha”);
hrg[i]=2000;
break;
case’S’:
case’s’:
strcpy(jns[i],”Sayap”);
hrg[i]=1500;
break;

default:
hrg[i]=0;
strcpy(jns[i],”–“);
break;
}
cout<<“Banyak Potong : “;cin>>bb[i];
jml[i]=hrg[i]*bb[i];

cout<<endl;
}
clrscr();
cout<<”          GEROBAK FRIED CHICKEN         “<<endl;
cout<<“________________________________________________”<<endl;
cout<<“No.   Jenis       Harga     Banyak    Jumlah   “<<endl;
cout<<”      Potong      Satuan    Pesan     Harga    “<<endl;
cout<<“________________________________________________”<<endl;

for(i=1;i<=n;i++){
cout<<setiosflags(ios::left)<<setw(7)<<i;
cout<<setiosflags(ios::left)<<setw(10)<<jns[i];
cout<<setiosflags(ios::right)<<“RP”<<setw(6)<<hrg[i];
cout<<setiosflags(ios::right)<<setw(5)<<bb[i];
cout<<setprecision(4)<<”        Rp.”<<jml[i]<<endl;
}

cout<<“________________________________________________”<<endl;

for(i=1;i<=n;i++){
if(i==1){
jml_byr=jml[i];
}else if(i<=2)
jml_byr=jml[i]+jml[i];

}
cout<<”                        Jumlah Bayar  Rp.”<<jml_byr<<endl;

pjk=0.1*jml_byr;
cout<<”                        Pajak 10%         Rp. “<<pjk<<endl;

tbl=jml_byr+pjk;
cout<<”                        Total Bayar   Rp.”<<tbl<<endl;

cout<<endl;
cout<<“Mau coba Lagi ???!! [Y/N]”<<endl;cin>>awal;
if (awal==’y’||awal==’Y’)
goto awal;
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