public class operasi_aritmatika
{
public static void main(String[] args)
{
//angka yang digunakan
int i = 37;
int j = 42;
double x = 27.475;
double y = 7.22;
System.out.println("Nilai dari variable-varible : ");
System.out.println("i = "+i);
System.out.println("j = "+j);
System.out.println("x = "+x);
System.out.println("y = "+y);
//Penjumlahan angka
System.out.println("Penjumlahan...");
System.out.println("i + j = "+(i+j));
System.out.println("x + y = "+(x+y));
//Pengurangan angka
System.out.println("Pengurangan...");
System.out.println("i - j = "+(i-j));
System.out.println("x - y = "+(x-y));
//Perkalian angka
System.out.println("Perkalian");
System.out.println("i * j = "+(i*j));
System.out.println("x * y = "+(x*y));
//Pembagian angka
System.out.println("Pembagian angka");
System.out.println("i / j = "+(i/j));
System.out.println("x / y = "+(x/y));
//Modulus pembagian
System.out.println("Menghitung sisa bagi...");
System.out.println("i % j = "+(i%j));
System.out.println("x % y = "+(x%y));
}
}
/*Selain tipe data integer dan double, java juga mampu menangani tipe data float (pecahan) dan char (karakter). Simpan dengan nama file operasi_aritmatika.java*/
0 komentar:
Posting Komentar