CONTOH PROGRAM BULAN DENGAN CASE DALAM BAHASA JAVA
PROGRAMNYA
:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Scanner;
import javax.swing.JOptionPane;
public class case_bulan
{
public static void main(String[]args)
{
//yogi.king.pratama@blogspot.com
Scanner masuk=new Scanner(System.in);
BufferedReader dataIn=new BufferedReader(new
InputStreamReader(System.in));
int p;
System.out.print("Masukkan
bulan[1...12]:");
p=masuk.nextInt();
switch(p)
{
case 2:
System.out.println("jumlah harinya 28
atau 29 hari");break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
System.out.println("jumlah harinya
31") ;break;
case 4:
case 6:
case 9:
case 11:
System.out.println("jumlah harinya
30") ;break;
default:
System.out.println("anda salah kode
bulan") ;break;
}
}
}
HASIL
OUTPUT :
Tidak ada komentar:
Posting Komentar