TUGAS STRUKTUR DATA PERTEMUAN 2
Nama: Silva Raja
Nim: 11160696
Kelas: 11.2A.07
STMIK NUSA MANDIRI WARUNG JATI
------------------------------------------------------------------------------------------
1] Array Berdimensi 1
#include <conio.h>
#include <iostream.h>
#include <iomanip.h>
#include<string>
main()
{
char lagi,kr[5],*jr[10];
int i,bj,hs[5],br[5],jh[10],totbay,jb=0;
float pajak;
atas:
clrscr();
cout<<" NURI BAKERY \n ";
cout<<"-----------------------------------------"<<endl;
cout<<"Kode Jenis Harga "<<endl;
cout<<"-----------------------------------------"<<endl;
cout<<"B ROTI BAKAR 10000 "<<endl;
cout<<"I ROTI ISI 5000 "<<endl;
cout<<"T ROTI TAWAR 12000 "<<endl;
cout<<"-----------------------------------------------\n";
cout<<"Banyak jenis : ";cin>>bj;
for(i=1;i<=bj;i++)
{
cout<<"Jenis ke- "<<i<<endl;
cout<<"Kode roti[B/I/T]: ";cin>>kr[i];
cout<<"Banyak roti : ";cin>>br[i];
cout<<"=============================\n\n\n";
}
cout<<"=================================================\n";
cout<<" Nuri Bakery \n";
cout<<"=================================================\n";
cout<<"NO Jenis Harga Banyak Jumlah\n";
cout<<" Roti Satuan Roti Harga\n";
cout<<"=================================================\n";
for (i=1;i<=bj;i++)
{
if(kr[i]=='B' || kr[i]=='b')
{
hs[i]=10000;
jr[i]="ROTI BAKAR";
}
else if(kr[i]=='I' || kr[i]=='i')
{
hs[i]= 5000;
jr[i]="ROTI ISI";
}
else
{
hs[i]=12000;
jr[i]="ROTI TAWAR";
}
cout<<setiosflags(ios::left)<<setw(8)<<i;
cout<<setiosflags(ios::left)<<setw(10)<<jr[i];
cout<<setiosflags(ios::left)<<setw(15)<<hs[i];
cout<<setiosflags(ios::left)<<setw(10)<<br[i];
jh[i]=br[i]*hs[i];
jb=jb+jh[i];
cout<<setiosflags(ios::right)<<setw(5)<<jh[i]<<endl;
}
cout<<"==================================================\n";
cout<<"Jumlah bayar : "<<jb<<endl;
pajak=0.1*jb;
cout<<"Pajak 10% : "<<pajak<<endl;
totbay=jb+pajak;
cout<<"Total bayar : "<<totbay<<endl;
cout<<"==================================================\n";
cout<<"INGIN INPUT LAGI?[Y/T]";cin>>lagi;
clrscr();
if(lagi=='y'||lagi=='Y')
goto atas;
else if(lagi=='t'||lagi=='T')
cout<<"\t **** Terima Kasih **** ";
getch();
}
Output:
1. output pertama yang akan ditampilkan.
3. Setelah itu akan keluar berapa jumlah harga dan jumlah bayar serta pajak yang dikenakan.
Jika ingin menginput lagi ketik Y dan jika tidak ketik T.
2] Array Berdimensi 2
#include <conio.h>
#include <stdio.h>
#include <iostream.h>
#include <iomanip.h>
main()
{
int i, j;
int data_jual[3][3];
clrscr();
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
cout<<"Data Ke - "<<i<<" "<<j<<endl;
cout<"Jumlah Penjulan : "; cin>>data_jual[i][j];
}
}
cout<<"Data Penjualan Pertahun"<<endl;
cout<<"-----------------------"<<endl;
cout<<"NO 2015 2016 "<<endl;
cout<<"-----------------------"<<endl;
for(i=1;i<=2;i++)
{
cout<<setiosflags(ios::left)<<setw(5)<<i;
for(j=1;j<=2;j++)
{
cout<<setiosflags(ios::right)<<setw(4);
cout<<data_jual[i][j];
cout<<" ";
}
cout<<endl;
}
cout<<"-----------------------"<<endl;
getch( );
}
Komentar
Posting Komentar