Senin, 13 Juni 2011

Tugas Algoritma dan Pemrograman 7

SOAL:


bentuk input
----------------------------
Masukan nama Kasir         :
Masukan Nama Pembeli    :

input jumlah Data    :

Data ke- 1
Input Kode Barang      :
Input Jumlah Barang    :

data ke-2
Input Kode Barang      :
Input Jumlah Barang    :

----------------------------
Bentuk Output
----------------------------

Kasir        : Fadli                              No. Faktur    : F-001
Pembeli    : Asmara Jati                    Tanggal         : 28-10-1981
----------------------------------------------------------------------------------------
 No.    Nama              Harga            Qty            Jumlah 
Urut    Barang             Satuan                            Harga
----------------------------------------------------------------------------------------

1.       Pensil              Rp. 500            5             Rp. 2.500
2.       Pulpen            Rp. 1.500        10            Rp. 15.000

-----------------------------------------------------------------------------------------
                Total Bayar                    Rp. 17.500
                Uang Bayar                    Rp. 20.000
                Kembali                         Rp. 2.500
-------------------------------------------------------------------------------------------
                 T E R I M A     K A S I H   
-------------------------------------------------------------------------------------------

Input Data Lagi [Y/T] :


List

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

main()
{
char namap[50], namak[50], tgl[50], lanjut, ulangi;
char kode[10] = {'1','2','3','4','5','6','7','8','9','10'}, *namab[10];
long hasat[10], jumhar[10], totbar[10];
long bayar, kembali;
int jumbel[10];
int x, y, z = 0;
clrscr();
cout<<"\n\n\t\tNama Kasir = ";gets(namak);
cout<<"\n\n\t\tTanggal Transaksi[dd/mm/yyyy] = ";gets(tgl);
cout<<"\n\n\t\tKasir saat ini "<<namak;
cout<<"\n\n\n\t\tPress Anykey To Countinue . . .";
lanjut = getche();
if(lanjut == 'Q')
    goto program;
else
    goto program;
program:
clrscr();
cout<<"\n\t\tMasukan Nama Pembeli = ";gets(namap);
cout<<"\t\tJumlah Data = ";cin>>y;
totbar[y] = 0;
    for (x = 1; x <= y; x++)
       {
      cout<<"\n\t\t----------------------";
       cout<<"\n\t\tData Ke-"<<x;
      cout<<"\n\n\t\tInput Kode Barang = ";cin>>kode[x];
          if(kode[x] == '1')
             {
            namab[x] = "Buku";
            hasat[x] = 3500;
            }
         else if (kode[x] == '2')
            {
            namab[x] = "Pensil";
             hasat[x] = 2000;
            }
         else if (kode[x] == '3')
             {
            namab[x] = "Pulpen";
            hasat[x] = 2500;
            }
         else if (kode[x] == '4')
             {
            namab[x] = "Penggaris";
            hasat[x] = 2500;
            }
         else if (kode[x] == '5')
             {
            namab[x] = "Serutan";
            hasat[x] = 2000;
            }
         else if (kode[x] == '6')
             {
            namab[x] = "Penghapus";
            hasat[x] = 2000;
            }
            else if (kode[x] == '7')
             {
            namab[x] = "Tipe-x";
            hasat[x] = 4000;
            }
            else if (kode[x] == '8')
             {
            namab[x] = "Spidol";
            hasat[x] = 5000;
            }
            else if (kode[x] == '9')
            {
            namab[x] = "Stabilo";
             hasat[x] = 3000;
            }
            else if (kode[x] == 10)
             {
            namab[x] = "Tempat Alat Tulis";
             hasat[x] = 5000;
            }
         else
             {
             cout<<"\nKode yang ada Masukan Salah.\n";
            goto program;
            }
      cout<<"\t\tAnda Memilih        = "<<namab[x];
      cout<<"\n\t\tDengan Harga Satuan = "<<hasat[x]<<endl;
      cout<<"\t\tInput Jumlah Beli   = ";cin>>jumbel[x];
      jumhar[x] = hasat[x] * jumbel[x];
      totbar[y] = totbar[y] + hasat[x] * jumbel[x];
      }
cout<<"\n\t\tAda Kesalahan? [Y/T] ";
ulangi = getche();
    if (ulangi == 'Y' || ulangi == 'y')
      goto program;
bill:
clrscr();
cout<<"\nKasir = "<<namak;
cout<<setiosflags(ios::right)<<setw(55)<<"No faktur : FN-00"<<z<<endl;
cout<<"Pembeli = "<<namap;
cout<<setiosflags(ios::right)<<setw(46)<<"Tanggal = "<<tgl<<endl;
cout<<"--------------------------------------------------------------------------------";
cout<<" No         Nama              Harga             Qty          Jumlah   \n";
cout<<"Unit       Barang            Satuan                               Harga    \n";
cout<<"--------------------------------------------------------------------------------";
   for(x = 1; x <= y; x++)
       {
      cout<<setiosflags(ios::left)<<setw(11)<<x;
      cout<<setiosflags(ios::left)<<setw(19)<<namab[x];
      cout<<setiosflags(ios::left)<<setw(19)<<hasat[x];
        cout<<setiosflags(ios::left)<<setw(17)<<jumbel[x];
        cout<<setiosflags(ios::left)<<setw(10)<<jumhar[x]<<endl;
      }
cout<<"--------------------------------------------------------------------------------\n";
cout<<setiosflags(ios::right)<<setw(66)<<"Total Bayar = "<<totbar[y]<<endl;
cout<<setiosflags(ios::right)<<setw(66)<<"Uang Bayar  = ";cin>>bayar;
    if(bayar >= totbar[y])
        kembali = bayar - totbar[y];
   else
       goto bill;
cout<<setiosflags(ios::right)<<setw(66)<<"Kembalian   = "<<kembali<<endl;
cout<<"\n\n--------------------------------------------------------------------------------";
cout<<"\n\t\t\t\tTERIMA KASIH";
cout<<"\n--------------------------------------------------------------------------------";
cout<<"\n\nAnda Ingin Input Lagi? [Y/T] ";
ulangi = getche();
    if (ulangi == 'Y' || ulangi == 'y')
       {
      z++;
       goto program;
      }
   else
       goto akhir;
akhir:
getch();
}


Tampilan



Download Link

Jumat, 22 April 2011

Tugas Algoritma dan Pemrograman 5

Soal

Sebuah perusahaan ayam goreng dengan nama “GEROBAK FRIED
CHICKEN” yang telah lumayan banyak pelanggannya, ingin dibantu dibuatkan
program untuk membantu kelancaran usahaannya.
GEROBAK FRIED CHICKEN” mempunyai daftar harga ayam sebagai
berikut :
Kode Jenis Harga
----------------------------------
D Dada Rp. 2500
P Paha Rp. 2000
S Sayap Rp. 1500
----------------------------------
Buatlah programnya dengan ketentuan:
• Setiap pembeli dikenakan pajak sebesar 10% dari pembayaran.
• Banyak Jenis, Jenis Potong dan Banyak Beli diinput.
• Tampilan yang diinginkan sebagai berikut:
Layar Masukkan
GEROBAK FRIED CHICKEN
---------------------
Kode Jenis Harga
--------------------------
D Dada Rp. 2500
P Paha Rp. 2000
S Sayap Rp. 1500
--------------------------
Banyak Jenis : ... <diinput>
Jenis Ke - ... <proses counter>
Jenis Potong [D/P/S] : ... <diinput>
Banyak Potong : ... <diinput>
<<Terus berulang tergantung Banyak Jenis>>
Layar Keluaran
GEROBAK FIRED CHICHEN
-------------------------------------------------------------
No. Jenis Harga Bayak Jumlah
Potong Satuan Beli Harga
-------------------------------------------------------------
... ....... .... .... Rp ....
... ....... .... .... Rp ....
------------------------------------------------------------
Jumlah Bayar Rp ....
Pajak 10% Rp ....
Total Bayar Rp ....


List



#include <iostream.h>

#include <stdio.h>

#include <conio.h>

#include <iomanip.h>

#include <string.h>

main()

{

int x ,a ,ulangi;

char jenis[6] = {'D','d','P','p','S','s'} ,*ket[6];

long bapot[6], jumhar[6] = {0}, hasat[6] = {2500 ,2000 ,1500};

long jumbar[6]= {0}, pajak[6], totba[6];

pesan:

clrscr();

cout<<"\tGEROBAK FRIED CHICKEN\n";

cout<<"\t---------------------\n";

cout<<"\t Kode Jenis Harga\n";

cout<<"\t---------------------\n";

cout<<"\t [D] Dada  Rp. 2500\n";

cout<<"\t [P] Paha  Rp. 2000\n";

cout<<"\t [S] Sayap Rp. 1500\n\n";

cout<<"\t---------------------\n\n";

cout<<"\tBanyak Jenis : ";cin>>x;

jumbar[x] = 0;

            if (x <= 0)

   {

   cout<<"\n\t\tBanyak Jenis Tidak Boleh Null";

   goto akhir;

   }

   else

   {

                        for(a = 1 ; a <= x; ++a)

            {

      cout<<"\tJenis Ke - "<<a;

                        cout<<"\n\tJenis Potong [D/P/S] : ";cin>>jenis[a];

                        cout<<"\tBanyak Potongan : ";cin>>bapot[a];

      cout<<"\t------------------------\n";

                        if (jenis[a] == 'D' || jenis[a] == 'd')

            {

                                    ket[a] = "Dada ";

                                    hasat[a] = 2500;

            }

                        else if (jenis[a] == 'P' || jenis[a] == 'p')

            {

            ket[a] = "Paha ";

                                    hasat[a] = 2000;

            }

                        else if (jenis[a] == 'S' || jenis[a] == 's')

            {

            ket[a] = "Sayap";

                                    hasat[a] = 1500;

            }

                        else

                                    {

                        cout<<"\nAnda Salah Masukan Kode Jenis Potongan.";

                        hasat[a] = 0;

                        }

      jumhar[a] = hasat[a] * bapot[a];

      jumbar [x] = jumbar[x] + hasat[a] * bapot[a];

            if (jumbar[x] == 0)

            {

            pajak[x] = 0;

            totba[x] = 0;

            }

         else

            {

                                                pajak[x] = jumbar[x] * 0.1;

                                                totba[x] = jumbar[x] + pajak[x];

            }

      }

   }

cout<<"\n\n\tGEROBAK FRIED CHICKEN\n";

cout<<"------------------------------------------------\n";

cout<<"No.| Jenis     | Harga     | Banyak | Jumlah\n";

cout<<"   | Potong    | Satuan    | Beli   | Harga\n";

cout<<"================================================\n";

            for (a = 1; a <= x; ++a)

   {

            cout<<" "<<a<<" | "<<ket[a]<<"     | "<<hasat[a];

   cout<<"      | "<<bapot[a]<<"      | Rp. "<<jumhar[a]<<endl;

            }

cout<<"------------------------------------------------\n";

cout<<"\t\t\tJumlah Bayar  Rp. "<<jumbar[x]<<endl;

cout<<"\t\t\tPajak 10%     Rp. "<<pajak[x]<<endl;

cout<<"\t\t\tTotal Bayar   Rp. "<<totba[x];

cout<<"\n\n\tAnda Ingin Memesan Lagi? [Y/T] = ";

ulangi = getche();

            if (ulangi == 'Y' || ulangi == 'y')

            goto pesan;

   else

            cout<<"\n\n\t\tTerima Kasih";

akhir:

getch();
}

Tampilan

Download link
Disini