Formatif pra UTS semester 2

soal tipe 7

scriptnya :

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

using namespace std;

int main()
{
string n_pasien,n_kemasan,kode_kemasan;
int jml_beli,harga,ttl_bayar,uang_bayar,uang_kembali;
cout<<“——–APOTIK TIFFANY—–“<<endl;
cout<<“nama pasien : “;
cin>>n_pasien;
cout<<“kode kemasan : B=Botol | K=Kaplet | T=Tub”<<endl;
cout<<“kode kemasan (b/k/t) : “;
cin>>kode_kemasan;
cout<<“jumlah beli : “;
cin>>jml_beli;
cout<<endl;

if(kode_kemasan == “B” || kode_kemasan == “b”)
{n_kemasan = “Botol”;
harga = 50000;
}
else if(kode_kemasan == “K” || kode_kemasan == “k”)
{
n_kemasan = “Kaplet”;
harga = 25000;
}
else if(kode_kemasan == “T” || kode_kemasan == “t”)
{
n_kemasan = “Tub”;
harga = 40000;
}
ttl_bayar = harga * jml_beli;
cout<<” Uang bayar Rp. “;
cin>>uang_bayar;
uang_kembali=uang_bayar-ttl_bayar;

if(“uang_bayar<uang_kembali”)
{
uang_kembali;
}
cout<<endl;

 

cout<<“——–PENJUALAN APOTIK TIFFANY——— “<<endl;
cout<<” Nama pasien : ” <<n_pasien<<endl;
cout<<” kemasan : ” <<n_kemasan<<endl;
cout<<” harga : ” <<harga<<endl;
cout<<” Total Bayar : ” <<ttl_bayar<<endl;
cout<<” Uang Bayar : ” <<uang_bayar<<endl;
cout<<” Uang Kembali : ” <<uang_kembali<<endl;

 

}

 

berikut tampilan input dan output jika kita running scriptnya :

gg

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s