Pertemuan Ke-6
Jumat, 08 Juni 2012
public class Switch1
{
public static void main(String[] args)
{
String namaPasien = "Raclien";
String namaKamar = "a";
char kodeKamar = 'B';
int lamaPerawatan = 7;
int biayaObat = 750000;
int biayaDokter = 250000;
int biayaKamar = 0;
int biayaTotal = 0;
switch(kodeKamar)
{
case 'A':
namaKamar = "Anggrek";
biayaKamar = 350000;
break;
case 'B':
namaKamar = "Dahlia";
biayaKamar = 200000;
break;
case 'C':
namaKamar = "Mawar";
biayaKamar = 150000;
break;
case 'D':
namaKamar = "Bangsal";
biayaKamar= 50000;
break;
default:
System.out.println("Tidak Ada Kode Kamar "+kodeKamar);
}
biayaTotal = (lamaPerawatan*biayaKamar) + biayaObat + biayaDokter;
System.out.println("");
System.out.println("--------Daftar Pembayaran---------");
System.out.println("-------------RS Mugas-------------");
System.out.println("==================================");
System.out.println("Nama Pasien : "+namaPasien);
System.out.println("Kode Kamar : "+kodeKamar);
System.out.println("Nama Kamar : "+namaKamar);
System.out.println("Lama Perawatan ; "+lamaPerawatan);
System.out.println("Biaya Kamar Per Hari : "+biayaKamar);
System.out.println("Biaya Obat : "+biayaObat);
System.out.println("Biaya Dokter : "+biayaDokter);
System.out.println("Biaya Total : "+biayaTotal);
System.out.println("==================================");
}
}
Hasil dari skrip di atas adalah:
0 komentar:
Posting Komentar