Wednesday 8 June 2011

tugas 9


Buatlah program untuk menghitung besarnya diskon yang diberikan atas besarnya sejumlah pembelian dengan ketentuan sebagai berikut :
-jika belanja dibawah Rp. 1000000 maka tidak mendapatkan diskon
-jika belanja di mulai dari Rp 1000000 sampai dengan Rp 5000000 , maka mendapat diskon sebesar 20%
-jika belanja di atas Rp 5000000 , maka mendapat diskon sebesar 35%
Fungsi yang harus di buat potong() untuk menghitung besar potongan yang akan diberikan dengan tampilan yang diinginkan sebagai berikut :
PROGRAM HITUNG POTONGAN
Besar pembelian barang Rp ……….. <di input>
Besar diskon yang diberikan Rp ……………… <hasil proses>
Besar harga yang harus di bayarkan Rp………….. <hasil proses>


#include<conio.h>
#include<stdio.h>
#include<iostream.h>
potong(long int *pembelian_barang,long int *diskon)
{
if(*pembelian_barang>5000000)
*diskon=*pembelian_barang*35/100;
else
if(*pembelian_barang>=1000000 && *pembelian_barang<=5000000)
*diskon=*pembelian_barang*20/100;
else
*diskon=0;
}
main()
{
long int pmbelian,dskn,total;
cout<<"PROGAM HITUNG POTONGAN"<<endl;
cout<<endl;
cout<<"Besar Pembelian Barang Rp. ";cin>>pmbelian;
cout<<endl;
potong(&pmbelian,&dskn);
cout<<"Besar Diskon yang diberikan Rp. "<<dskn<<endl;
total=pmbelian-dskn;
cout<<"Besar Harga yang harus dibayarkan Rp. "<<total<<endl;
getch();
}


tugas 8


Buatlah program header di bawah ini , kemudian  simpan dengan nama : hitnilai.h , pada folder kerja anda folder include
/*hitnilai.h
*/
#define awal {
#define akhir }
#define mulai() main()
#define cetak cout
#define tampil cprintf
#define masuk scanf
#define hapus() clrscr()
#define jika if
#define warna textcolor
#define tahan getche()

Simpan pada direktori C:\BC5\INCLUDE\..... , selanjutnya compile file hitnilai.h .

Buatlah program di bawah ini , kemudian gunakan header  yang sudah anda buat ..

/*-----------------------------------*/
/*program dengan file header sendiri*/
/*----------------------------------*/
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include "hitnilai.h"
mulai()
awal
                int absen,tugas1,UTS1,UAS1,nilai,absensi,tugas2,UTS2,UAS2,nilaiakhir;
   hapus();
   warna(4);
   tampil("\nPROGRAM MENGHITUNG NILAI AKHIR MATA KULIAH\n");
   cout<<endl;
   cout<<"Masukkan Nilai Absensi : ";cin>>absen;
   cout<<"Masukkan Nilai Tugas : ";cin>>tugas1;
   cout<<"Masukkan Nilai U.T.S : ";cin>>UTS1;
   cout<<"Masukkan Nilai U.A.S : ";cin>>UAS1;
   absensi = absen*10/100;
   tugas2 = tugas1*20/100;
   UTS2 = UTS1*30/100;
   UAS2 = UAS1*40/100;
   nilaiakhir = absensi+tugas2+UTS2+UAS2;
   cout<<endl;
   cout<<"----------------------------------------------------";
   cout<<endl;
   cout<<"\tNilai Murni Absensi = "<<absen;
   cout<<" * 10% = "<<absensi<<endl;
   cout<<"\tNilai Murni Tugas = "<<tugas1;
   cout<<" * 20% = "<<tugas2<<endl;
   cout<<"\tNilai Murni U.T.S = "<<UTS1;
   cout<<" * 30% = "<<UTS2<<endl;
   cout<<"\tNilai Murni U.A.S = "<<UAS1;
   cout<<" * 40% = "<<UAS2;
   cout<<endl;
   cout<<"\tNilai Akhir yang diperoleh sebesar : "<<nilaiakhir;
   cout<<endl;
   cout<<"-----------------------------------------------------";
   tahan;
akhir






Tugas 7


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

main()
{
char namap[50], namak[50], tgl[50], lanjut, ulangi;
char *namab[9];
long hasat[9], jumhar[9], totbar[9];
long bayar, kembali;
int jumbel[9], kode[9] = {1,2,3,4,5,6,7,8,9};
int x, y, z = 0;
clrscr();
cout<<"\n\n\t\tNama Kasir = ";gets(namak);
cout<<"\n\n\t\tTanggal Login [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] < 1 || kode[x] > 9)
                {
            clrscr();
                cout<<"\n\t\tKode yang ada Masukan Salah.\n";
            cout<<"\n\t\tPress Anykey to Continue . . .";
            ulangi = getche();
                if (ulangi == 'Q')
                                goto program;
               else
                  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();
}





Saturday 23 April 2011

Tugas 6 c++

#include<constrea.h>
#include<stdio.h>
class sewa
{
public:
char kode[5],*judul,*pengarang;
int lama;
long int denda;
};
main()
{
char bulan[20],nm_peminjam[25],lagi[1];
int i,j;
float totbay;
totbay=0;
sewa buku[10];
atas:
clrscr();
cout<<" CITRA LIBRARY \n";
cout<<" PERUMNAS 2 Telp.(021)789567 \n";
cout<<"-----------------------------------------------------\n";
cout<<"Bulan : ";gets(bulan);
cout<<"Nama peminjam : ";gets(nm_peminjam);
cout<<"Masukkan jumlah data : ";cin>>j;
cout<<endl;
for(i=1;i<=j;i++)
{
cout<<"Data ke -"<<i<<endl;
cout<<"Kode buku [AADC/AAC/EIL] : ";cin>>buku[i].kode;
if(strcmpi(buku[i].kode,"AADC")==0)
{buku[i].judul="Ada Apa Dengan Cinta";
buku[i].pengarang="Mira Lesmana";}
else
if(strcmpi(buku[i].kode,"AAC")==0)
{buku[i].judul="Ayat-ayat Cinta";
buku[i].pengarang="Kang Abik";}
else
if(strcmpi(buku[i].kode,"EIL")==0)
{buku[i].judul="Eiffel I'm In Love";
buku[i].pengarang="Nia Dinata";}
cout<<"Judul buku : "<<buku[i].judul<<endl;
cout<<"Pengarang : "<<buku[i].pengarang<<endl;
cout<<"Lama pinjam : ";cin>>buku[i].lama;
if(buku[i].lama>7)
buku[i].denda=10000;
else
buku[i].denda=0;
cout<<endl;
}
clrscr();
cout<<" CITRA LIBRARY \n";
cout<<" PERUMNAS 2 Telp.(021)789567 \n";
cout<<"******************************************************\n";
cout<<"Bulan : "<<bulan<<endl;
cout<<"Nama peminjam : "<<nm_peminjam<<endl;
cout<<"------------------------------------------------------------------------\n";
cout<<"No. Kode Judul Pengarang Lama Denda \n";
cout<<" Buku Buku Sewa \n";
cout<<"------------------------------------------------------------------------\n";
for(i=1;i<=j;i++)
{
cout<<setiosflags(ios::left)<<setw(5)<<i;
cout<<setiosflags(ios::left)<<setw(7)<<buku[i].kode;
cout<<setiosflags(ios::left)<<setw(12)<<buku[i].judul;
cout<<setiosflags(ios::left)<<setw(14)<<buku[i].pengarang;
cout<<setiosflags(ios::right)<<setw(10)<<buku[i].lama;
cout<<setiosflags(ios::right)<<setw(10)<<buku[i].denda<<endl;
totbay=totbay+buku[i].denda;
}
cout<<"------------------------------------------------------------------------\n";
cout<<"Total bayar : Rp."<<setprecision(10)<<totbay<<endl;
cout<<endl;
cout<<"Mau input lagi ? [Y/T] : ";cin>>lagi;
if(strcmpi(lagi,"Y")==0)
goto atas;
else
getch();
}
hasil runnya bisa di coba sendiri ya disini

TUGAS 5, cpp

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 ....





Script





#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();

}