#include <conio.h>
#include <iostream.h>
#include <iomanip.h>
main()
{
int i;
char nama[5][20];
float nilai1[5];
float nilai2[5];
double hasil[5];
clrscr();
for(i=1;i<=3;i++)
{
cout<<"Data Ke - "<<i<<endl;
cout<<"Nama Siswa :";gets(nama[i]);
cout<<"Nilai Uts :";cin>>nilai1[i];
cout<<"Nilai Uas :";cin>>nilai2[i];
hasil[i]=(nilai1[i]*0.40+(nilai2[i]*0.60));
cout<<endl;
}
cout<<"--------------------------------------------"<<endl;
cout<<"No. Nama Siswa Nilai Nilai Hasil"<<endl;
cout<<" UTS UAS Ujian"<<endl;
cout<<"--------------------------------------------"<<endl;
for(i=1;i<=3;i++)
{
cout<<setiosflags(ios::left)<<setw(6)<<i;
cout<<setiosflags(ios::left)<<setw(10)<<nama[i];
cout<<setprecision(25)<<" "<<nilai1[i];
cout<<setprecision(15)<<" "<<nilai2[i];
cout<<setprecision(15)<<" "<<hasil[i]<<endl;
}
cout<<"--------------------------------------------"<<endl;
getch();
}
2. Array Dimensi Dua
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <iomanip.h>
main(){
int bd,b,bb[5],hrg[5],tot[5],jbay=0,pjk,tb,byr,kembali;
char jb[5][7],kb[5],lagi;
atas:
cout<<" VANRRY FLORIST "<<endl;
cout<<"==============================="<<endl;
cout<<"Kode Jenis Bunga Harga"<<endl;
cout<<" T Tulip Rp.250000"<<endl;
cout<<" L Lily Rp.200000"<<endl;
cout<<" M Mawar Rp.150000"<<endl;
cout<<"==============================="<<endl;
cout<<"Banyak Data : ";cin>>bd;
for(b=1;b<=bd;b++)
{
cout<<"jenis ke- "<<b<<endl;
cout<<"kode Bucket[T/L/M] : ";cin>>kb[b];
cout<<"banyak bucket : ";cin>>bb[b];
if(kb[b]=='T'||kb[b]=='t')
{
strcpy(jb[b],"Tulip");
hrg[b]=250000;
}
else if(kb[b]=='L'||kb[b]=='l')
{
strcpy(jb[b],"Lily");
hrg[b]=200000;
}
else if(kb[b]=='M'||kb[b]=='m')
{
strcpy(jb[b],"Mawar");
hrg[b]=150000;
}
else{goto akhir;}
tot[b]=hrg[b]*bb[b];
}
clrscr();
cout<<" VANRRY FLORIST "<<endl;
cout<<"========================================="<<endl;
cout<<"No Jenis Harga Banyak Jumlah"<<endl;
cout<<" Bucket Satuan Beli Harga "<<endl;
cout<<"========================================="<<endl;
for(b=1;b<=bd;b++)
{
cout<<setiosflags(ios::left)<<setw(4)<<b;
cout<<setiosflags(ios::left)<<setw(9)<<jb[b];
cout<<setiosflags(ios::left)<<setw(8)<<hrg[b];
cout<<setiosflags(ios::left)<<setw(9)<<bb[b];
cout<<setiosflags(ios::left)<<setw(4)<<tot[b]<<endl;
jbay=jbay+tot[b];
}
cout<<"========================================="<<endl;
cout<<" jumlah bayar :Rp."<<jbay<<endl;
pjk=0.1*jbay;
cout<<" pajak 10% :Rp."<<pjk<<endl;
tb=jbay+pjk;
cout<<" total bayar :Rp."<<tb<<endl;
cout<<" uang bayar :Rp.";cin>>byr;
kembali=byr-tb;
cout<<" uang kembali :Rp."<<kembali<<endl;
cout<<"Ingin input lagi [Y/T] : ";cin>>lagi;
if(lagi=='Y'||lagi=='y')
{clrscr();
goto atas;}
else{
clrscr();
cout<<"THANK YOU";}
getch();
akhir:
}
Tidak ada komentar:
Posting Komentar