Koding NetBeans yang Menampilkan Hasil Penjumlahan, Pengurangan, Perkalian dan Pembagian
public class Pertemuan {
public static void main(String[] args) {
int nilai1 = 3;
int nilai2 = 4;
int penjumlahan;
penjumlahan = nilai1+nilai2;
System.out.println("Nilai 1="+nilai1);
System.out.println("Nilai 2="+nilai2);
System.out.println ("Hasil Penjumlahan = "+penjumlahan);
System.out.println ("===================================================");
int nilai3 = 7;
int nilai4 = 4;
int pengurangan;
pengurangan = nilai3-nilai4;
System.out.println("Nilai 1="+nilai3);
System.out.println("Nilai 2="+nilai4);
System.out.println ("Hasil Pengurangan = "+pengurangan);
System.out.println ("===================================================");
int nilai5 = 3;
int nilai6 = 4;
int perkalian;
perkalian = nilai5*nilai6;
System.out.println("Nilai 1="+nilai5);
System.out.println("Nilai 2="+nilai6);
System.out.println ("Hasil Perkalian = "+perkalian);
System.out.println ("===================================================");
int nilai7 = 8;
int nilai8 = 4;
int pembagian;
pembagian = nilai7/nilai8;
System.out.println("Nilai 1="+nilai7);
System.out.println("Nilai 2="+nilai8);
System.out.println ("Hasil Pembagian = "+pembagian);
System.out.println ("===================================================");
}
}
Maka akan tampil seperti pada gambar di bawah ini :
Menghitung Luas Persegi Panjang, Persegi, Segitiga, Jajaran Genjang dan Layang-layang
package pertemuan;
public class Pertemuan {
public static void main(String[] args) {
int p = 3;
int l = 4;
int Luas_Persegi_Panjanng;
Luas_Persegi_Panjanng = p*l;
System.out.println("Panjang = "+p);
System.out.println("Lebar = "+l);
System.out.println ("Hasil Luas Persegi Panjang= "+Luas_Persegi_Panjanng);
System.out.println ("===================================================");
int s1 = 7;
int s2 = 7;
int Luas_Persegi;
Luas_Persegi = s1*s2;
System.out.println("Sisi 1="+s1);
System.out.println("Sisi 2="+s2);
System.out.println ("Hasil Luas Persegi = "+Luas_Persegi);
System.out.println ("===================================================");
double a = 3;
double t = 4;
double Luas_Segitiga;
Luas_Segitiga = 0.5*a*t;
System.out.println("Alas = "+a);
System.out.println("Tinggi = "+t);
System.out.println ("Hasil Luas Segitiga = "+Luas_Segitiga);
System.out.println ("===================================================");
int A = 8;
int T = 4;
int Luas_Jajaran_Genjang;
Luas_Jajaran_Genjang = A*T;
System.out.println("Alas="+A);
System.out.println("Tinggi="+T);
System.out.println ("Hasil Luas Jajaran Genjang = "+Luas_Jajaran_Genjang);
System.out.println ("===================================================");
double d1 = 8;
double d2 = 9;
double Luas_Layang_layang;
Luas_Layang_layang = 0.5*d1*d2;
System.out.println("Diagonal 1="+d1);
System.out.println("Diagonal 2="+d2);
System.out.println ("Hasil Luas Layang-layang = "+Luas_Layang_layang);
System.out.println ("===================================================");
}
}
Tidak ada komentar:
Posting Komentar