package tugas;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Tugas {
public static void main(String[] args) throws IOException {
Integer pilih=null;
Double hasil,r,pj,le, alas, tinggi, luas = null,dg1,dg2,ss1,ss2 ;
Double phi = 3.14 ;
BufferedReader ieu=new BufferedReader(new InputStreamReader(System.in) );
try
{
System.out.println("=====================================");
System.out.println("PROGRAM PERHITUNGAN LUAS BANGUN DATAR ");
System.out.println("=====================================");
System.out.println(" SULUNG SUGANDA");
System.out.println(" 3125 111 182 ");
System.out.println("=====================================");
System.out.println("1. Persegi");
System.out.println("2. Segitiga");
System.out.println("3. Lingkaran");
System.out.println("4. Layang-layang");
System.out.println("5. Trapesium");
System.out.println("=====================================");
System.out.print("Masukkan pilihan -> ");
pilih= Integer.parseInt(ieu.readLine());
}
catch (NumberFormatException e)
{
System.out.println("Inputan harus angka !");
}
catch (Exception e)
{
System.out.println(" Erroor !");
}
switch (pilih)
{
case 1:
System.out.println("==================== ");
System.out.println("Hitung Luas persegi ");
System.out.println("==================== ");
System.out.print("Masukkan Panjang = ");
pj = Double.valueOf(ieu.readLine());
System.out.print("Masukkan lebar = ");
le = Double.valueOf(ieu.readLine());
hasil=pj*le;
System.out.println("Luas persegi dengan");
System.out.println("Panjang "+pj+" & lebar "+le+" Adalah "+hasil);
break;
case 2:
System.out.println("==================== ");
System.out.println("Hitung Luas Segitiga ");
System.out.println("==================== ");
System.out.print("Masukkan Alas = ");
alas = Double.valueOf(ieu.readLine());
System.out.print("Masukkan Tinggi = ");
tinggi = Double.valueOf(ieu.readLine());
hasil=alas*tinggi/2;
System.out.println("Luas Segitiga dengan");
System.out.println("Alas "+alas+" & tinggi "+tinggi+" Adalah "+hasil);
break;
case 3:
System.out.println("==================== ");
System.out.println("Hitung Luas Lingkaran ");
System.out.println("==================== ");
System.out.print("Masukkan jari-jari = ");
r = Double.valueOf(ieu.readLine());
hasil=phi*r*r;
System.out.println("Luas Lingkaran dengan");
System.out.println("Jari-jari "+r+" Adalah "+hasil);
break;
case 4:
System.out.println("========================== ");
System.out.println("Hitung Luas Layang-layang ");
System.out.println("========================== ");
System.out.print("Masukkan diagonal-1 = ");
dg1 = Double.valueOf(ieu.readLine());
System.out.print("Masukkan diagonal-2 = ");
dg2 = Double.valueOf(ieu.readLine());
hasil=dg1*dg2/2;
System.out.println("Luas layang-layang dengan");
System.out.println("Diagonal-1 "+dg1+" & Diagonal-2 "+dg2+" Adalah "+hasil);
break;
case 5:
System.out.println("======================== ");
System.out.println("Hitung Luas Trapesium ");
System.out.println("======================== ");
System.out.print("Masukkan sisi-1 = ");
ss1 = Double.valueOf(ieu.readLine());
System.out.print("Masukkan sisi-2 = ");
ss2 = Double.valueOf(ieu.readLine());
System.out.print("Masukkan tinggi = ");
tinggi = Double.valueOf(ieu.readLine());
hasil=ss1+ss2*tinggi/2;
System.out.println("Luas Trapesium dengan");
System.out.println("sisi-1 "+ss1+" sisi-2 "+ss2+" & tinggi "+tinggi+" Adalah "+hasil);
break;
}
}
}