D4n9k3l's Blog
Just another WordPress.com weblog

Switch Case

Contoh Program menggunakan Fungsi Switch Case :

#include<conio.h>
#include<stdio.h>
#include<iostream>
main()
{
char kode, ulang, *namabarang;
long int harga, jumlah_beli, total, total_bayar, diskon;

izy:
clrscr();
cout<<“PROGRAM TOKO TRIPLE S” ;
cout<<“\n===================” ;
cout<<“\n\nMasukkan Kode Barang [A/B/C/] : “;cin>>kode;
switch(kode)
{
case ‘A’:
case ‘a’:
namabarang=”TV LG”;
harga=2500000;
break;
case ‘B’:
case ‘b’:
namabarang=”TV Sharp”;
harga=1750000;
break;
case ‘C’:
case ‘c’:
namabarang=”TV Sanyo”;
harga=1500000;
break;
default:
cout<<“\nANDA SALAH MEMASUKKAN KODE :P”;
break;
}
cout<<“\n=========================” ;
cout<<“\nNama Barang  : “<<namabarang<<endl;
cout<<“Harga  : “<<harga<<endl;
cout<<“\n=========================” ;
cout<<“\nJumlah Beli : ” ;cin >>jumlah_beli;
total=harga*jumlah_beli;
if (jumlah_beli>=5)
diskon=0.1 * total;
else
diskon=0 * total;
total_bayar = total – diskon;
cout<<“\n\tTotal : “<<total<<endl;
cout<<“\tDiskon : “<<diskon<<endl;
cout<<“\tTotal Bayar : “<<total_bayar<<endl;
printf(“\n Anda Ingin Ulang Lagi [Y/T] : “);
ulang = getche();
cout<<“\n\n\tProgrammed by Iz! a.K.a D4n9k3l 2009 :D” ;
if (ulang == ‘Y’ || ulang == ‘y’)
goto izy;
getch();
}

Belum Ada Tanggapan to “Switch Case”

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: