Latihan Kombinasi Array Structure di Borland c++
Sabtu, 09 Maret 2013
Borland C++
Coding
Latihan Kombinasi Array Structure di Borland c++
berikut listing yang bisa rekan-rekan pelajari :
//PROGRAM STRUCTURE DAN ARRAY
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <iomanip.h>
garis()
{
cout<<" "<<endl;
}
main()
{
struct
{
char nm[20];
float kdmenu,h,jb,th;
}menu[10] ;
int i,j;
clrscr();
cout<<"\t\tDAFTAR MENU MAKANAN"<<endl;
cout<<"\t\t1. Soto Ceker "<<endl;
cout<<"\t\t2. Mie Aceh"<<endl;
cout<<"\t\t3. Bakso Solo"<<endl;
garis();
cout<<"\t\tMasukan Jumlah Data : ";cin>>j;
garis();
for (i=1;i<=j;i++)
{
cout<<"Data Ke - : "<<i<<endl;
cout<<"Pilih Menu [1/2/3] : ";cin>>menu[i].kdmenu;
cout<<"Jumlah Beli : ";cin>>menu[i].jb;
if (menu[i].kdmenu==1)
{
strcpy(menu[i].nm,"Soto Ceker");
menu[i].h=11000;
}
else if (menu[i].kdmenu==2)
{
strcpy(menu[i].nm,"Mie Aceh");
menu[i].h=12000;
}
else
{
strcpy(menu[i].nm,"Bakso Solo");
menu[i].h=13000;
}
menu[i].th=menu[i].jb*menu[i].h;
}
clrscr();
cout<<"\t\tRESTO QT@ - QT@"<<endl;
garis();
cout<<"No. Nama Harga/ Jumlah Total "<<endl;
cout<<" Makanan Porsi Beli Harga "<<endl;
garis();
for (i=1;i<=j;i++)
{
cout<<setiosflags(ios::left)<<setw(2)<<i;
cout<<setprecision(5)<<" "<<menu[i].nm;
cout<<setprecision(5)<<" "<<"Rp"<<ends<<menu[i].h;
cout<<setprecision(5)<<" "<<menu[i].jb;
cout<<setprecision(5)<<" "<<"Rp"<<ends<<menu[i].th;
cout<<endl;
}
getch();
}