Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Simple_Calculate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package operator;
import java.util.*;
public class Kalkulator_sederhana {
public static void main(String[] args) {
double a,b, hasil;
char Operator;

Scanner Input = new Scanner(System.in);
System.out.print("Input Value 1 = ");
a = Input.nextDouble();

System.out.print("Input Operator = ");
Operator = Input.next().charAt(0);

System.out.print("Input Value 2 = ");
b = Input.nextDouble();

System.out.println("Input User :" +a+ " " +Operator+ " " +b);

if ( Operator == '+'){
hasil = a + b;
System.out.println("Hasil = " +hasil);
} else if (Operator == '-'){
hasil = a - b;
System.out.println("Hasil = " +hasil);
} else if (Operator == '*'){
hasil = a * b;
System.out.println("Hasil = " +hasil);
} else if (Operator == '/'){
if (b == 0) {
System.out.println("Setiap Pembagian Dengan Nol Akan Menghasilkan Nilai Tak Hingga!!");
} else {
hasil = a / b;
System.out.println("Hasil = " +hasil);
}
} else {
System.out.println("Operator Tidak Ditemukan!!");
}
}
}