Skip to content

Instantly share code, notes, and snippets.

@erikgunawan erikgunawan/Aritmatika
Last active Aug 29, 2015

Embed
What would you like to do?
Program Operasi Dasar Aritmatika 2 Bilangan dengan Java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* @Developer : Erik Gunawan
* @Nickname : EXz
* @Phone : 0896 5332 0577
* @EMail : admin@erikgunawan.com
* @Gmail : erik.gunawan44@gmail.com
* @Website : www.erikgunawan.com
* @Facebook : facebook.com/revolutionist.exz
* @Twitter : twitter.com/_EXz
*/
public class Aritmatika {
private static BufferedReader br = null;
public static void main(String[] args) {
System.out.println("Program Aritmatika");
System.out.println("==================");
System.out.println();
boolean cek = true;
while (cek) {
br = new BufferedReader(new InputStreamReader(System.in));
try {
System.out.print("Masukkan bilangan pertama: ");
int bil1 = Integer.parseInt(br.readLine());
System.out.print("Masukkan bilangan kedua: ");
int bil2 = Integer.parseInt(br.readLine());
System.out.println();
int penjumlahan = bil1 + bil2;
int pengurangan = bil1 - bil2;
int perkalian = bil1 * bil2;
double pembagian = (double)bil1 / (double)bil2;
System.out.println("Hasil penjumlahan : " + bil1 + " + " + bil2 + " = " + penjumlahan);
System.out.println("Hasil pengurangan : " + bil1 + " - " + bil2 + " = " + pengurangan);
System.out.println("Hasil perkalian : " + bil1 + " * " + bil2 + " = " + perkalian);
System.out.println("Hasil pembagian : " + bil1 + " / " + bil2 + " = " + pembagian);
System.out.println();
System.out.print("Ingin coba lagi (Y/N) ? ");
String coba = br.readLine();
if (coba.equalsIgnoreCase("N"))
cek = false;
else if (coba.equalsIgnoreCase("Y"))
cek = true;
else
System.exit(0);
}
catch (IOException ioe) {
System.out.println("Error IOException");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.