STRUCT
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<iomanip.h>
garis()
{cout<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"<<endl;}
main()
{
struct
{char kd[20],nm[20],pak[30];
float hrg,stock;}
menu[30];
char hr[30],nmks[20];
int i,j,ts,th;
th=0;
ts=0;
clrscr();
cout<<endl;
cout<<"\t\t INPUT DATA BARANG
"<<endl;
cout<<"\t\t RUMAH MAKAN ENAK
"<<endl;
cout<<endl;
garis();
cout<<endl;
cout<<"Hari Mencatat: ";cin>>hr;
cout<<"Nama Pencatat: ";cin>>nmks;
cout<<"Jumlah Data di input:
";cin>>j;
cout<<endl;
garis();
for(i=1;i<=j;i++)
{
cout<<endl;
cout<<" Data
ke-"<<i<<endl;
cout<<" Masukan Kode Makanan[A/B/C]:
";cin>>menu[i].kd;
cout<<" Jumlah Stock: ";cin>>menu[i].stock;
if(!strcmp(menu[i].kd,"a")||!strcmp(menu[i].kd,"A"))
{strcpy(menu[i].nm,"NASGOR+AYAM");
strcpy(menu[i].pak,"paket A");
menu[i].hrg=50000;}
else if
(!strcmp(menu[i].kd,"B")||!strcmp(menu[i].kd,"b"))
{strcpy(menu[i].nm,"NASGOR+BAKSO");
strcpy(menu[i].pak,"paket
B");
menu[i].hrg=15000;}
else if
(!strcmp(menu[i].kd,"c")||!strcmp(menu[i].kd,"c"))
{strcpy(menu[i].nm,"NASGOR+UDANNG");
strcpy(menu[i].pak,"paket C");
menu[i].hrg=35000;}
cout<<endl;
garis();
}
clrscr();
cout<<endl;
cout<<"\t\t DAFTAR STOCK MENU"<<endl;
cout<<"\t\t RUMAH MAKAN ENAK
BANGET"<<endl;
cout<<"\t\t Hari Input: "<<hr<<endl;
cout<<"\t\t Nama Kasir: "<<nmks<<endl;
cout<<endl;
garis();
cout<<endl;
cout<<"No. Menu Satuan Harga Stock"<<endl;
cout<<endl;
garis();
cout<<endl;
for(i=1;i<=j;i++)
{
cout<<setiosflags(ios::left)<<setw(1)<<i;
cout<<setprecision(8)<<" "<<menu[i].nm;
cout<<setprecision(8)<<" "<<menu[i].pak;
cout<<setprecision(8)<<"
"<<"Rp"<<ends<<menu[i].hrg;
cout<<setprecision(8)<<"
"<<menu[i].stock<<endl;
ts=ts+menu[i].stock;
th=th+menu[i].hrg;
}
cout<<endl;
garis();
cout<<endl;
cout<<"Jumlah Stock :\t\t\t\t\t"<<ts<<endl;
cout<<"Jumlah Harga :\t\t\tRp "<<th<<endl;
cout<<endl;
garis();
getch();
}
Gambar
Hasil Coding C++