import java.util.Scanner;
public class Kalkulator {
public static void main(String[] args) {
System.out.println("*****************************");
System.out.println("Kalkulator Sederhana ");
System.out.println("****************************");
System.out.println("");
Scanner input = new Scanner(System.in);
Scanner ulang = new Scanner(System.in);
String lagi = "";
do {
double a, b;
System.out.print("Masukkan Angka Pertama: ");
a = input.nextDouble();
System.out.print("Masukkan Angka Kedua: ");
b = input.nextDouble();
double jumlah = a+b;
double kurang = a-b;
double kali = a*b;
double bagi = a/b;
double modulus = a%b;
int pil;
System.out.println("");
System.out.println("1. Penjumlahan");
System.out.println("2. Pengurangan");
System.out.println("3. Perkalian");
System.out.println("4. Pembagian");
System.out.println("5. Modulus");
System.out.println("");
System.out.print("Masukkan Pilihan [1-5]: ");
pil = input.nextInt();
System.out.println("");
switch(pil) {
case 1 :
System.out.println(a + " + " + b + " = " +jumlah);
break;
case 2 :
System.out.println(a + " - " + b + " = " +kurang);
break;
case 3 :
System.out.println(a + " * " + b + " = " +kali);
break;
case 4 :
System.out.println(a + " / " + b + " = " +bagi);
break;
case 5 :
System.out.println(a + " % " + b + " = " +modulus);
break;
default:
System.out.println("Pilihan Salah");
break;
}
System.out.println("*******************************");
System.out.println("");
System.out.println("Apakah anda ingin input lagi? [y/t] ? ");
lagi = ulang.nextLine();
}
while (lagi.equals("y") || lagi.equals("Y"));
}
}
public class Kalkulator {
public static void main(String[] args) {
System.out.println("*****************************");
System.out.println("Kalkulator Sederhana ");
System.out.println("****************************");
System.out.println("");
Scanner input = new Scanner(System.in);
Scanner ulang = new Scanner(System.in);
String lagi = "";
do {
double a, b;
System.out.print("Masukkan Angka Pertama: ");
a = input.nextDouble();
System.out.print("Masukkan Angka Kedua: ");
b = input.nextDouble();
double jumlah = a+b;
double kurang = a-b;
double kali = a*b;
double bagi = a/b;
double modulus = a%b;
int pil;
System.out.println("");
System.out.println("1. Penjumlahan");
System.out.println("2. Pengurangan");
System.out.println("3. Perkalian");
System.out.println("4. Pembagian");
System.out.println("5. Modulus");
System.out.println("");
System.out.print("Masukkan Pilihan [1-5]: ");
pil = input.nextInt();
System.out.println("");
switch(pil) {
case 1 :
System.out.println(a + " + " + b + " = " +jumlah);
break;
case 2 :
System.out.println(a + " - " + b + " = " +kurang);
break;
case 3 :
System.out.println(a + " * " + b + " = " +kali);
break;
case 4 :
System.out.println(a + " / " + b + " = " +bagi);
break;
case 5 :
System.out.println(a + " % " + b + " = " +modulus);
break;
default:
System.out.println("Pilihan Salah");
break;
}
System.out.println("*******************************");
System.out.println("");
System.out.println("Apakah anda ingin input lagi? [y/t] ? ");
lagi = ulang.nextLine();
}
while (lagi.equals("y") || lagi.equals("Y"));
}
}
Jika masih bingung bisa lihat video tutorial dibawah ini ya 😁😁
No comments:
Post a Comment