switch Case

#include <iostream.h>
#include <conio.h>
int main ()
{
char nama[20];
char Gol;
float gaji,tunj,total;
gaji=0;
total=0;
tunj=0;
cout << “Nama pegawai : “;
cin >> nama;
cout << endl << “Golongan ( 1-3 ) : “;
cin >> Gol;

switch (Gol)
{

case ‘1’:
{
gaji=300000;
tunj=200000;
break;
}

case ‘2’:
{
gaji=600000;
tunj=250000;
break;
}

case ‘3’:
{
gaji=1500000;
tunj=300000;
break;
}

default : cout << endl << “Yang anda masukkan salah!”;

}
total=gaji+tunj;

cout << “\nStruk gaji bulan Maret”;
cout << “\nGaji : Rp. ” << gaji;
cout << “\ntunjangan : Rp. ” << tunj;
cout << “\nJumlah : Rp. ” << total;
getch ();
return 0;
}

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: