Latest

02:56 AM Latihan Soal Agama (3)

Latihan dan Jawaban Program  C++ Perpustakaan


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

tarif();

//variabel global digunakan pada main dan fungsi tarif
char kode;
int jml_pinjam, harga;
float jml_byr;

main()
{
    //variabel untuk main
    char nama[25];

    cout <<"Perpustakaan Kecil-Kecilan\n";
    cout <<"----------------------------\n\n";
    cout <<"Nama Penyewa Buku : "; gets(nama);
    cout <<"Kode Buku [C/K/N] : "; cin >>kode;
    cout <<"Banyak Pinjam     : "; cin >>jml_pinjam;

    clrscr();
    tarif();   //pemanggilan fungsi tarif
    cout <<endl;
    cout <<"Penyewa dengan Nama : "<<nama<<endl;
    jml_byr = harga * jml_pinjam;
    cout <<"Jumlah Bayar Penyewaan Sebesar Rp. "<<jml_byr;
    getch();
}

tarif()
{
   //variabel lokal fungsi tarif
    char *jenis;

     if (kode=='C' || kode =='c')
       {
          jenis = "Cerpen (Cerita Pendek)";
         harga = 500;
      }
     if (kode=='K' || kode =='k')
       {
          jenis = "Komik";
         harga = 700;
      }
     if (kode=='N' || kode =='n')
       {
          jenis = "Novel";
         harga = 1000;
      }
   cout <<"Tarif Sewa Rp.\t : " <<harga<<endl;
    cout <<"Jenis Buku \t : " <<jenis<<endl;
}
06 Apr 2014

Post a Comment

Emoticon
:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

 
Top