Cari Blog Ini

Selasa, 24 April 2012

contoh listing C++ array


#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <iomanip.h>
main()
{
int banyak,r;                                  
char kode[10],rasa[10][20];
int harga[10],babel[10],juga[10],juyar=0,ppn,total;
clrscr();
puts("\t\t********************************");
puts("\t\t\tKERIPIK SEJUTA UMAT");
puts("\t\t********************************");
puts("\t\tKODE RASA         HARGA");
puts("\t\t********************************");
puts("\t\tC   COKLAT        Rp7000/bungkus");
puts("\t\tK   KEJU          Rp6000/bungkus");
puts("\t\tS   SAPI PANGGANG Rp5000/bungkus");
puts("\t\tJ   JAGUNG BAKAR  Rp5500/bungkus");
puts("\t\t********************************");
cout<<"banyak rasa:";cin>>banyak;
for(r=1;r<=banyak;r++)
{
cout<<"\nrasa no:"<<r;
cout<<"\npilihan rasa[C/K/S/J]:";cin>>kode[r];
cout<<"\nbanyak beli:";cin>>babel[r];
cout<<endl;

if(kode[r]=='C'||kode[r]=='c')
{strcpy(rasa[r],"coklat");
harga[r]=7000;
}
else if(kode[r]=='K'||kode[r]=='k')
{strcpy(rasa[r],"keju");
harga[r]=6000;}
else if(kode[r]=='S'||kode[r]=='s')
{strcpy(rasa[r],"sapi panggang");
harga[r]=5500;
}
else
{
strcpy(rasa[r],"jagung bakar");
harga[r]=5000;}
juga[r]=(harga[r]*babel[r]);
juyar=(juyar+juga[r]);
ppn=juyar*10/100;
total=juyar+ppn;}
cout<<endl;
puts("==========================================================");
puts("\t\tKERIPIK SEJUTA UMAT");
puts("==========================================================");
puts("No. pilihan rasa     harga satuan banyak beli jumlah harga");
puts("==========================================================");
cout<<endl;
for(r=1;r<=banyak;r++)
{
cout<<r<<"  ";
cout<<setiosflags(ios::left)<<setw(19)<<rasa[r];
cout<<setiosflags(ios::left)<<setw(15)<<harga[r];
cout<<setiosflags(ios::left)<<setw(15)<<babel[r];
cout<<setiosflags(ios::left)<<setw(15)<<juga[r];
cout<<endl;
}
puts("============================================================");
cout<<"\t\t\t\t\tJUMLAH BAYAR   :"<<juyar<<endl;
cout<<"\t\t\t\t\tPPN 10%              :"<<ppn<<endl;
cout<<"\t\t\t\t\tTOTAL BAYAR      :"<<total<<endl;
getch();
}




Tidak ada komentar:

Posting Komentar