import java.util.*;
public class HitungLuas
{
public static void main(String args[]){
final double PHI=3.14;
double sisi;
double panjang;
double lebar;
double alas;
double tinggi;
double jari2;
double luas;
Scanner in = new Scanner(System.in);
System.out.println("Menghitung Luas Geometri");
System.out.println("========================");
System.out.println("1.Bujur Sangkar");
System.out.println("2.Persegi Panjang");
System.out.println("3.Segitiga");
System.out.println("4.Lingkaran");
System.out.println("");
System.out.print("Masukan Pilihan Anda :");
int input=in.nextInt();
switch(input)
{
case 1 :
System.out.println("");
System.out.println("Menghitung Luas Bujur Sangkar ...");
System.out.print("Masukan Sisi :");
sisi=in.nextDouble();
luas=sisi*sisi;
System.out.println("Luas = " + luas);
break;
case 2:
System.out.println("");
System.out.println("Menghitung Luas Persegi Panjang ...");
System.out.print("Masukan Panjang :");
panjang=in.nextDouble();
System.out.print("Masukan Lebar :");
lebar=in.nextDouble();
luas=panjang*lebar;
System.out.println("Luas = " + luas);
break;
case 3 :
System.out.println("");
System.out.println("Menghitung Luas Segitiga ...");
System.out.print("Masukan Alas :");
alas=in.nextDouble();
System.out.print("Masukan Tinggi :");
tinggi=in.nextDouble();
luas=0.5*alas*tinggi;
System.out.println("Luas = " + luas);
break;
case 4 :
System.out.println("");
System.out.println("Menghitung Luas Lingkaran ...");
System.out.print("Masukan jari-jari :");
jari2=in.nextDouble();
luas=PHI*jari2*jari2;
System.out.println("Luas = " + luas);
break;
}
}
}
public class HitungLuas
{
public static void main(String args[]){
final double PHI=3.14;
double sisi;
double panjang;
double lebar;
double alas;
double tinggi;
double jari2;
double luas;
Scanner in = new Scanner(System.in);
System.out.println("Menghitung Luas Geometri");
System.out.println("========================");
System.out.println("1.Bujur Sangkar");
System.out.println("2.Persegi Panjang");
System.out.println("3.Segitiga");
System.out.println("4.Lingkaran");
System.out.println("");
System.out.print("Masukan Pilihan Anda :");
int input=in.nextInt();
switch(input)
{
case 1 :
System.out.println("");
System.out.println("Menghitung Luas Bujur Sangkar ...");
System.out.print("Masukan Sisi :");
sisi=in.nextDouble();
luas=sisi*sisi;
System.out.println("Luas = " + luas);
break;
case 2:
System.out.println("");
System.out.println("Menghitung Luas Persegi Panjang ...");
System.out.print("Masukan Panjang :");
panjang=in.nextDouble();
System.out.print("Masukan Lebar :");
lebar=in.nextDouble();
luas=panjang*lebar;
System.out.println("Luas = " + luas);
break;
case 3 :
System.out.println("");
System.out.println("Menghitung Luas Segitiga ...");
System.out.print("Masukan Alas :");
alas=in.nextDouble();
System.out.print("Masukan Tinggi :");
tinggi=in.nextDouble();
luas=0.5*alas*tinggi;
System.out.println("Luas = " + luas);
break;
case 4 :
System.out.println("");
System.out.println("Menghitung Luas Lingkaran ...");
System.out.print("Masukan jari-jari :");
jari2=in.nextDouble();
luas=PHI*jari2*jari2;
System.out.println("Luas = " + luas);
break;
}
}
}
1 komentar:
wawwww hebat brow