Senin, 31 Oktober 2016

latihan IF

LIST PROG "IF"

#include<stdio.h>
#include<conio.h>
#include<iostream.h>
main()
{
char kd,judul[20],np[20],bonus[20],jwb;
int jumbel;
float harsat,j_pemby,dis,harber,tunj;
awal:
textbackground(0);
clrscr();
cout<<" \n             toko kaset utama  \n"<<endl;
cout<<"nama pembeli : ";cin>>np;
cout<<"kode [1/2/3] : ";cin>>kd;
cout<<"jumlah beli  : ";cin>>jumbel;
cout<<"\n###################################"<<endl<<endl;
if(kd=='1')
{
                strcpy(judul,"we will not gaza tonight");
   strcpy(bonus,"boneka cantik");
   harsat=18000;
}
else if(kd=='2')
{
                strcpy(judul,"hero");
   strcpy(bonus,"mug lucu");
   harsat=20000;
}
else
{
                strcpy(judul,"i turn you");
   strcpy(bonus,"poster seru");
   harsat=21000;
}
j_pemby=harsat*jumbel;
if(jumbel>=5)
                dis=0.15*j_pemby;
else
                dis=0;
if(kd=='1'&&jumbel>=5)
                tunj=5000;
   else
   if(kd=='2'&&jumbel>=5)
   tunj=6000;
   else
   if(kd=='3'&&jumbel>=5)
   tunj=7000;
   else
   tunj=0;
harber = j_pemby-dis+tunj;
cout<<"judul lagu                                : "<<judul<<endl;
cout<<"bonus                                       : "<<bonus<<endl;
cout<<"harga                                        : "<<harsat<<endl;
cout<<"jumlah bayar           : "<<j_pemby<<endl;
cout<<"discount                  : "<<dis<<endl;
cout<<"tunjangan                                : "<<tunj<<endl;
cout<<"Total Bayar              : "<<harber<<endl<<endl;
cout<<"mau menghitung lagi[Y/T]?";jwb=getche();
if(jwb=='Y'||jwb=='Y')
goto awal;
getch();

}


Tidak ada komentar:

Posting Komentar