Senin, 19 Februari 2018

Program C ++ Sewa Buku

#include <iostream>
#include <stdio.h>
#include <conio.h>
using namespace std;

 int Phari, Pbln, Pthn,Khari, Kbln, Kthn,jenis,sewa,hrg,lamasewa,lambat,denda=0;  char nama[30], nim[10], kodeBuku[5],judul[30], pengarang[30], penerbit[30];
main(){  int byk;  cout<<"\n ==================================";  cout<<"\n       PROGRAM PENYEWAAN BUKU";
cout<<"\n ==================================";
cout<<"\n\n Nama       : "; gets(nama);
cout<<" No Anggota : "; cin>>nim;


cout<<"\n Jenis buku ";
cout<<"\n 1.Komik \n"; 
cout<<" 2.Novel \n"; 
cout<<" 3.Majalah \n\n";


cout<<"Banyak buku yg disewa : ";cin>>byk;
for(int i=1;i<=byk;i++)
{cout<<"\n\nJenis buku : ";cin>>jenis;   if(jenis==1)      hrg=1000;    else if(jenis==2)      hrg=2000;    else if(jenis==3)      hrg=3000;    else      hrg=0 ; 
cout<<"Harga sewa\t: "<<hrg; 
cout<<"\nKode Buku\t: "; gets(kodeBuku);
cout<<"Judul Buku\t: "; gets(judul);
cout<<"Pengarang\t: "; gets(pengarang);
cout<<"Penerbit\t: "; gets(penerbit);   sewa=sewa+hrg;   }


  //input tanggal sewa
cout<<"\n Tanggal Sewa: \n";  while(1){
cout<<" Tanggal [1 - 30]\t: "; cin>>Phari;    if(Phari<=0||Phari>30){      cout<<" ERROR...!\n";    }else{break;}  }  while(1){    cout<<" Bulan [1 - 12]\t\t: "; cin>>Pbln;    if(Pbln<=0||Pbln>12){      cout<<" ERROR...!\n";    }else{break;}  }  while(1){    cout<<" Tahun [yyyy]\t\t: "; cin>>Pthn;    if(Pthn<=0){
cout<<" ERROR...!\n";    }else{break;}  }


  //input tanggal pengembalian
cout<<"\n\n Tanggal Kembali: \n";  while(1){
cout<<" Tanggal [1 - 30]\t: "; cin>>Khari;    if(Khari<=0||Khari>30){
cout<<" ERROR...!\n";    }else{break;}  }  while(1){    cout<<" Bulan [1 - 12]\t\t: "; cin>>Kbln;    if(Kbln<=0||Kbln>12){      cout<<" ERROR...!\n";    }else{break;}  }  while(1){    cout<<" Tahun [yyyy]\t\t: "; cin>>Kthn;    if(Kthn<=0){
cout<<" ERROR...!\n";    }else{break;}  }


  //proses perhitungan  lamasewa = (Khari-Phari)+((Kbln-Pbln)*30)+((Kthn-Pthn)*360);
if(lamasewa>byk)  {lambat=lamasewa-byk; } //lamasewa - 7;  denda = lambat *100*byk;
cout<<"\nHarga total sewa : "<<sewa;
cout<<"\nHarga denda      : "<<denda;
cout<<"\nHarga total      : "<<sewa+denda;


  getch();
 
  }

Output tampilan 1 :


Output tampilan 2 :


Tidak ada komentar:

Posting Komentar