Sabtu, 15 Desember 2012

-BSI- Tugas UAS

#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <iomanip.h>

gr()
{puts("------------------------------");}

grs()
{puts("=========================================");}

garis()
{puts("==============================================================");}

int hitung(int x, int y)
{return x+y;
}

main()
{
 long int i, x, tb=0;
 char np[25], lg;
 struct
 {
  int jb;
  long int hr, tl;
  char kd, *mr;
  }oli[10];

atas:
clrscr();
gr();
cout<<"| Kode | Merk Oli    | Harga |"<<endl;
gr();
cout<<"|  1   | Penzoil     | 50000 |"<<endl;
cout<<"|  2   | Top One     | 40000 |"<<endl;
cout<<"|  3   | Shell Helix | 30000 |"<<endl;
cout<<"|  4   | Mesran      | 25000 |"<<endl;
gr();
cout<<endl;
grs();
cout<<"           DATA PENJUALAN OLI"<<endl;
cout<<"             SCEDURIA MOTOR"<<endl;
grs();
cout<<"Masukkan Nama Pembeli  = ";gets(np);
cout<<"Masukkan Jumlah Barang = ";cin>>x;
cout<<endl;
for(i=1;i<=x;i++)
{
cout<<"Data Penjualan Barang ke - "<<i<<endl;
cout<<"      Masukkan Kode Oli    = ";cin>>oli[i].kd;
cout<<"      Beli Barang          = ";cin>>oli[i].jb;
cout<<endl;

if(oli[i].kd=='1')
 {oli[i].mr="Penzoil";
  oli[i].hr=50000;}
else if(oli[i].kd=='2')
 {oli[i].mr="Top One";
  oli[i].hr=40000;}
else if(oli[i].kd=='3')
 {oli[i].mr="Shell Helix";
  oli[i].hr=30000;}
else
 {oli[i].mr="Mesran";
  oli[i].hr=25000;}

oli[i].tl=oli[i].jb*oli[i].hr;

tb=hitung(tb,oli[i].tl);
}


clrscr();
garis();
cout<<"|                     DATA PENJUALAN OLI                     |"<<endl;
cout<<"|                       SCEDURIA MOTOR                       |"<<endl;
garis();
cout<<setiosflags(ios::left)<<"| Nama Pembeli : "<<setw(43)<<np<<" |"<<endl;
garis();
cout<<"|No.| Kode |     Merk        | Jumlah |  Harga   |  Total    |"<<endl;
cout<<"|   | Oli  |     Oli         |        |          |           |"<<endl;
garis();
for(i=1;i<=x;i++)
{
cout<<setiosflags(ios::left)<<"| "<<setw(2)<<i;
cout<<setiosflags(ios::left)<<"| "<<setw(4)<<oli[i].kd;
cout<<setiosflags(ios::left)<<" | "<<setw(15)<<oli[i].mr;
cout<<setiosflags(ios::left)<<" | "<<setw(6)<<oli[i].jb;
cout<<setiosflags(ios::right)<<" | "<<setw(8)<<oli[i].hr;
cout<<setiosflags(ios::right)<<" | "<<setw(9)<<oli[i].tl<<" |";
cout<<endl;
}
garis();
cout<<setiosflags(ios::right)<<"| Total Pembayaran   "<<setw(39)<<tb<<" |"<<endl;
garis();
cout<<endl;
cout<<"Mau Input Data Lagi [Y/T] ? ";cin>>lg;
if(lg=='Y'||lg=='y')
goto atas;
getch();
}

Tidak ada komentar:

Posting Komentar