package praktikumpbo;
import javax.swing.JOptionPane;
/**
*
* @author AN
*/
public class soal4 {
public static void main (String []args){
int ulang = 0;
do{
String a=JOptionPane.showInputDialog("Mau Mu"
+"\n 1 Luas persegi panjang"
+"\n 2 Keliling Persegi Panjang"
+"\n 3 Luas Segitiga"
+"\n 4 Keliling Segitiga");
int pilihan=Integer.parseInt(a);
switch(pilihan){
case 1:
luaspersegi();
break;
case 2:
kelilingp();
break;
case 3:
luassegi();
break;
case 4:
keliling();
break;
}
}while(ulang==1);
}
private static void luaspersegi() {
String p=JOptionPane.showInputDialog("panjang");
double panjang=Double.parseDouble(p);
String l=JOptionPane.showInputDialog("lebar");
double lebar=Double.parseDouble(l);
double luas=panjang*lebar;
JOptionPane.showMessageDialog(null,"\n Luas Persegi panjang : "+luas);
}
private static void kelilingp() {
String p=JOptionPane.showInputDialog("panjang");
double panjang=Double.parseDouble(p);
String l=JOptionPane.showInputDialog("lebar");
double lebar=Double.parseDouble(l);
double K=2*(panjang+lebar);
JOptionPane.showMessageDialog(null,"\n keliling Persegi panjang : "+K);
}
private static void luassegi() {
String ab=JOptionPane.showInputDialog("Tinggi (AB)");
double tinggi=Double.parseDouble(ab);
String bc=JOptionPane.showInputDialog("Alas (BC)");
double alas=Double.parseDouble(bc);
double luas=(tinggi+alas)/2;
JOptionPane.showMessageDialog(null,"\n Luas Segitiga : "+luas);
}
private static void keliling() {
String ab=JOptionPane.showInputDialog("Tinggi (AB)");
double tinggi=Double.parseDouble(ab);
String bc=JOptionPane.showInputDialog("Alas (BC)");
double alas=Double.parseDouble(bc);
String cd=JOptionPane.showInputDialog("CD");
double garing=Double.parseDouble(cd);
double ks=tinggi+alas+garing;
JOptionPane.showMessageDialog(null,"\n keliling Segitiga : "+ks);
}
}