Program Pernyataan switch-case dengan strcpy |
/*filename = Program Pernyataan switch-case dengan strcpy */
/*Oleh : fk_seven */
/*Date : 14 Agustus 2011 */
#include <iostream.h>
#include <conio.h>
#include <string.h>
main()
{
char kode, barang[30];
char*brg;
int harga, jml, total;
gotoxy(17,3);cout<<"Latihan Switch - Case";
gotoxy(10,4);cout<<" -----------------------------";
gotoxy(10,6);cout<<"Masukkan Kode Barang [A ... C] : ";cin>>kode;
gotoxy(10,7);cout<<"Jumlah Beli : ";cin>>jml;
switch(kode)
{
case 'A':
gotoxy(10,9);cout<<"Nama Barang : Alat Olahraga";
harga=300000;
break;
case 'B':
gotoxy(10,9);cout<<"Nama Barang : Alat Elektronik";
harga=500000;
break;
case 'C':
gotoxy(10,9);cout<<"Nama Barang : Alat Memasak";
harga=100000;
break;
default:
gotoxy(10,8);cout<<"Salah Memasukkan KODE";
break;
}
total=jml*harga;
gotoxy(10,10);cout<<"Nama Barang : "<<strcpy(barang, brg);
gotoxy(10,11);cout<<"Harga Barang : "<<harga;
gotoxy(10,12);cout<<"Total Bayar : "<<total;
getch();
}
0 komentar:
Posting Komentar