Coding Java Aritmatika Sederhana

Berikut salah satu contoh coding menggunakan java.
merupakan coding aritmatika sederhana yang saya buat menggunakan fungsi switch-case.
silahkan dipelajari…
dan semoga bisa bermanfaat!!!



import java.io.*;
public class aritmatika_irfan{
public static void main(String[] args)
throws IOException{
System.out.println(“\n”);
System.out.println(” Syntax By IRFAN MAULANA”);
System.out.println(“——————————–“);
System.out.println(“\n”);
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
int bil1, bil2;
int pilihan;
System.out.println(“Pilihan Operasi :”);
System.out.println(“1. Perkalian”);
System.out.println(“2. Pembagian”);
System.out.println(“3. Penambahan”);
System.out.println(“4. Pengurangan”);
System.out.println(“\n”);
System.out.print(“Pilihan Operasi Yang Anda Inginkan : “);
pilihan=Integer.parseInt(br.readLine());
System.out.println(“\n”);
System.out.print(“Bilangan 1: “);
bil1=Integer.parseInt(br.readLine());
System.out.print(“Bilangan 2: “);
bil2=Integer.parseInt(br.readLine());
switch(pilihan){
case 1:
System.out.println(“Maka ” +bil1+” x “+bil2+” = “+ (bil1*bil2));
break;
case 2:
System.out.println(“Maka ” +bil1+” : “+bil2+” = “+ (bil1/bil2));
break;
case 3:
System.out.println(“Maka ” +bil1+” + “+bil2+” = “+ (bil1+bil2));
break;
case 4:
System.out.println(“Maka ” +bil1+” – “+bil2+” = “+ (bil1-bil2));
break;
}}}

*Nb : disimpan dengan nama aritmatika_irfan.java

Be a good reader, leave your comment please.

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