Sebelumnya sudah ada program untuk menghitung perkalian matriks 2x2. Sekarang, kita coba membuat Program Menu Olah Barang..
Seperti biasa,langsung di copy ajach...
//Program Olah Barang
#include <iostream>
#include <stdio>
#include <conio>
struct
{
int kode,harga;
char barang[100];
}data[10];
void input();
void keluar();
void transaksi();
int a,b,menu,n;
char bes=196,c=119,d=179;
main()
{
do
{
clrscr();
textcolor(10);gotoxy(30,7);cprintf("Program Olah Barang");
textcolor(14);gotoxy(27,8);cprintf("+++++++++++++++++++++++++");
textcolor(12);gotoxy(30,9);cprintf("Menu Pilihan");
textcolor(2);gotoxy(27,10);cprintf("1. Memasukkan Data Barang");
textcolor(1);gotoxy(27,11);cprintf("2. Melihat Data");
textcolor(3);gotoxy(27,12);cprintf("3. Transaksi");
textcolor(5);gotoxy(27,13);cprintf("4. Selesai");
textcolor(8);gotoxy(27,14);cprintf("Pilihan Anda: ");
textcolor(14);gotoxy(27,15);cprintf("+++++++++++++++++++++++++");
gotoxy(43,14);scanf("%d",&menu);
switch (menu)
{
case 1: input();break;
case 2: keluar();break;
case 3: transaksi();
break;
case 4:
{
clrscr();
gotoxy(20,10);textcolor(10);cprintf("Terima Kasih Telah Memakai Program :) \n");break;
}
}
}
while (menu!=4);
getch();
}
void input ()
{
clrscr();
cout<<"Masukkan Jumlah barang yang inginkan dimasukkan : ";
cin>>n;
for (int i=1;i<=n;i++)
{
cout<<"++++++++++++++++++++"<<endl;
cout<<"Masukkan Data Barang"<<endl;
cout<<"===================="<<endl;
cout<<"Masukkan Kode Barang : ";
cin>>data[i-1].kode;
cout<<"Masukkan Nama Barang : ";
cin>>data[i-1].barang;
cout<<"Masukkan Harga Barang : ";
cin>>data[i-1].harga;
cout<<"===================="<<endl;
}
cout<<endl;
getch();
}
void keluar()
{
clrscr();
for (int i=1;i<=n;i++)
{
cout<<"Data Barang"<<endl;
cout<<"===================="<<endl;
cout<<"Kode Barang : "<<data[i-1].kode<<endl;
cout<<"Masukkan Nama Barang : "<<data[i-1].barang<<endl;
cout<<"Masukkan Harga Barang : "<<data[i-1].harga<<endl;
cout<<"====================="<<endl;
}
cout<<endl;
getch();
}
void transaksi()
{
int dk,ag,ch,total;char nm[100],x;
clrscr();
lagi:
clrscr();
cout<<"------------------------------------"<<endl;
cout<<"Masukkan Kode Barang yang di Beli : ";
cin>>dk;
cout<<"Masukkan Nama Barang : ";
cin>>nm;
cout<<"Masukkan Harga Barang : ";
cin>>ag;
cout<<"Jumlah Barang yg dibeli : ";
cin>>ch;
total=ag*ch;
cout<<"Total Pembayaran"<<endl;
cout<<"------------------------------------"<<endl;
cout<<"Kode Barang: "<<dk<<endl;
cout<<"Nama Barang: "<<nm<<endl;
cout<<"Harga Barang: "<<ag<<endl;
cout<<"Jumlah Barang: "<<ch<<endl;
cout<<"Total Bayar: "<<total<<endl;
cout<<"Tekan enter untuk melanjutkan....";
getch();
clrscr();
ya:
cout<<"Anda ingin mengulangnya lagi (y/n) : ";
cin>>x;
if(x=='y')
goto lagi;
else if (x=='n')
{clrscr();
gotoxy(35,10);textcolor(12);cprintf("Terima Kasih...");}
else
goto ya;
getch();
}
++++++++++++++++++++++
Ingat Komentarnya yach....
Posting Komentar