RSS

Kalkulator Sederhana Bahasa Java

18 Aug

class kalkulator
{
public static void main(String[] args)
{

System.out.println(“===== Menu Kalkulator =====”);
System.out.println(“1. Penjumlahan”);
System.out.println(“2. Pengurangan”);
System.out.println(“3. Perkalian”);
System.out.println(“4. Pembagian”);
System.out.println(“”);

int a,b;
int pil;
String L;

do
{

System.out.print(“Masukan Bilangan A : “);
a=Integer.parseInt(System.console().readLine());

System.out.print(“Masukan Bilangan B : “);
b=Integer.parseInt(System.console().readLine());
System.out.println(“”);

System.out.print(“Masukan Pilihan Menu : “);
pil=Integer.parseInt(System.console().readLine());

switch(pil)

{

case 1 : System.out.println(“Hasil Penjumlahan : “+ (a+b));
break;
case 2 : System.out.println(“Hasil Pengurangan : “+ (a-b));
break;
case 3 : System.out.println(“Hasil Perkalian : “+ (a*b));
break;
case 4 : System.out.println(“Hasil Pembagian : “+ (a/b));
break;
default : System.out.println(“Inputan Anda Salah”);

}

System.out.println(“Ingin Lannjut Y/N: “);
L=System.console().readLine();

}

while (L.equalsIgnoreCase(“y”));

}
}

 
Leave a comment

Posted by on August 18, 2012 in Coding programing bahasa Java

 

Tags:

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: