Tugas Kuliah Logika Algoritma Jurusan Teknik Informatika dan Ilmu Komputer
Assalamualaikum. wr. wb.
Pada
artikel saya kali ini, saya akan membagikan hasil tugas logika algoritma saya kepada sobat
informatika.
Contoh Program C++ beserta
flowchart untuk Perhitungan transaksi
pembayaran sewa kamar balai pengobatan beserta diskon, dimana pasien yang lama
inap sama diatas 10 hari akan mendapatkan
diskon 5% dari jumblah bayarnya.
Program menggunakan perulangan while dan fungsi if – else
Berikut
flowchartnya :
>> Perbesar
untuk lebih melihat
jelas
Berikut script programmnya :
#include <iostream>
#include <string.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
char nop[20],nap[20],jeka[10];
int tarif,jumbay,disk,li,total,LI,kk;
cout<<"\nbp.KASIH IBU"<<endl;
cout<<"Perhitungan Transaksi Pembayaran Kamar Pasien"<<endl;
cout<<"Input Nomor Pasien :";cin>>nop;
cout<<"Input Nama Pasien :";cin>>nap;
cout<<"Kode Kamar"<<endl;
cout<<"1.R1"<<endl;
cout<<"2.R2"<<endl;
cout<<"3.R3"<<endl;
cout<<"Input Kode Kamar[1/2/3] :";cin>>kk;
cout<<"Input Lama Inap :";cin>>li;
cout<<"Lama Inap"<<endl;
cout<<"1.>10"<<endl;
cout<<"2.<10"<<endl;
cout<<"Input Pilihan :";cin>>LI;
if(kk==1 ){
strcpy (jeka,"Mawar");
tarif = 300000;
}
else if (kk==2){
strcpy (jeka,"Kemuning");
tarif = 200000;
}
else if (kk==3){
strcpy (jeka,"Flamboyan");
tarif = 150000;
}
else {
strcpy (jeka,"Tidak Tersedia");
tarif = 0;
}
jumbay = li * tarif;
switch (LI){
case 1:
disk = 0.05*jumbay;
break;
case 2:
disk = 0;
break;
}
total = jumbay-disk;
cout<<"==============================="<<endl;
cout<<" Balai Pengobatan 'KASIH IBU'"<<endl;
cout<<"==============================="<<endl;
cout<<"---------Struk Pembayaran--------"<<endl;
cout<<"Nomor Pasien :"<<nop<<endl;
cout<<"Nama Pasien :"<<nap<<endl;
cout<<"Jenis Kamar :"<<jeka<<endl;
cout<<"Tarif perHari :"<<tarif<<endl;
cout<<"Jumlah Bayar :"<<jumbay<<endl;
cout<<"Discount :"<<disk<<endl;
cout<<"Total Bayar :"<<total<<endl;
cout<<"---------------------------------"<<endl;
return 0;
}
#include <string.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
char nop[20],nap[20],jeka[10];
int tarif,jumbay,disk,li,total,LI,kk;
cout<<"\nbp.KASIH IBU"<<endl;
cout<<"Perhitungan Transaksi Pembayaran Kamar Pasien"<<endl;
cout<<"Input Nomor Pasien :";cin>>nop;
cout<<"Input Nama Pasien :";cin>>nap;
cout<<"Kode Kamar"<<endl;
cout<<"1.R1"<<endl;
cout<<"2.R2"<<endl;
cout<<"3.R3"<<endl;
cout<<"Input Kode Kamar[1/2/3] :";cin>>kk;
cout<<"Input Lama Inap :";cin>>li;
cout<<"Lama Inap"<<endl;
cout<<"1.>10"<<endl;
cout<<"2.<10"<<endl;
cout<<"Input Pilihan :";cin>>LI;
if(kk==1 ){
strcpy (jeka,"Mawar");
tarif = 300000;
}
else if (kk==2){
strcpy (jeka,"Kemuning");
tarif = 200000;
}
else if (kk==3){
strcpy (jeka,"Flamboyan");
tarif = 150000;
}
else {
strcpy (jeka,"Tidak Tersedia");
tarif = 0;
}
jumbay = li * tarif;
switch (LI){
case 1:
disk = 0.05*jumbay;
break;
case 2:
disk = 0;
break;
}
total = jumbay-disk;
cout<<"==============================="<<endl;
cout<<" Balai Pengobatan 'KASIH IBU'"<<endl;
cout<<"==============================="<<endl;
cout<<"---------Struk Pembayaran--------"<<endl;
cout<<"Nomor Pasien :"<<nop<<endl;
cout<<"Nama Pasien :"<<nap<<endl;
cout<<"Jenis Kamar :"<<jeka<<endl;
cout<<"Tarif perHari :"<<tarif<<endl;
cout<<"Jumlah Bayar :"<<jumbay<<endl;
cout<<"Discount :"<<disk<<endl;
cout<<"Total Bayar :"<<total<<endl;
cout<<"---------------------------------"<<endl;
return 0;
}
Berikut hasil run programnya :
>> Perbesar untuk lebih melihat jelas
Nah, semoga tugas program c++ dan flowchart saya ini bisa bermanfaat untuk dijadikan referensi bagi sobat informatika sekalian.