Program java :
import javax.swing.JOptionPane;
public class bujursangkar1
{
public static void main(String args[])
{
String first;String second;int number1;int number2; int sum;
first=JOptionPane.showInputDialog("Masukkan sisi Bujur sangkar:");
number1=Integer.parseInt(first);
sum=number1*number1;
JOptionPane.showMessageDialog(null,"Luas bujur sangkar adalah: "+sum,"Hasil",JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}
2. Menghitung Volume KUBUS rumus: SISI * SISI * SISI
Program java :
import javax.swing.JOptionPane;
public class kubus
{
public static void main(String args[])
{
String first;String second;int number1;int number2; int sum;
first=JOptionPane.showInputDialog("Masukkan sisi Kubus :");
number1=Integer.parseInt(first);
sum=number1*number1*number1;
JOptionPane.showMessageDialog(null,"Volume Kubus adalah: "+sum,"Hasil",JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}
3.Menghitung Keliling bujur sangkar rumus: 4 * SISI
Program java :
import javax.swing.JOptionPane;
public class kell_bujursangkar
{
public static void main(String args[])
{
String first;String second;int number1;int number2; int sum;
first=JOptionPane.showInputDialog("Masukkan sisi Bujur sangkar:");
number1=Integer.parseInt(first);
sum=4*number1;
JOptionPane.showMessageDialog(null,"Keliling bujur sangkar adalah: "+sum,"Hasil",JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}
4.Menghitung Luas persegi panjang rumus: panjang * lebar
Program java :
import javax.swing.JOptionPane;
public class persegipanjang
{
public static void main(String args[])
{
String first;String second;String three;int number1;int number2; int sum;
first=JOptionPane.showInputDialog("Masukkan panjang :");
second=JOptionPane.showInputDialog("Masukkan lebar :");
number1=Integer.parseInt(first);
number2=Integer.parseInt(second);
sum=number1*number2;
JOptionPane.showMessageDialog(null,"Luas persegi panjang adalah : "+sum,"Hasil",JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}
5.Menghitung Keliling persegi panjang rumus: (2 * panjang) * (2 * lebar)
Program java :
import javax.swing.JOptionPane;
public class kell_persegipanjang
{
public static void main(String args[])
{
String first;String second;String three;int number1;int number2; int sum;
first=JOptionPane.showInputDialog("Masukkan panjang :");
second=JOptionPane.showInputDialog("Masukkan lebar :");
number1=Integer.parseInt(first);
number2=Integer.parseInt(second);
sum=(2*number1)+(2*number2);
JOptionPane.showMessageDialog(null,"Keliling persegi panjang adalah : "+sum,"Hasil",JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}
6.Menghitung Luas Lingkaran rumus: 3,14 * (jari-jari)
Program java :
import javax.swing.JOptionPane;
public class luaslingkaran
{
public static void main(String args[])
{
String first;int number1;int sum;
first=JOptionPane.showInputDialog("Masukkan jari-jari lingkaran");
number1=Integer.parseInt(first);
sum=22/7*number1*number1;
JOptionPane.showMessageDialog(null,"Luas lingkaran adalah: "+sum,"Hasil",JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}
7. Menghitung Keliling Lingkaran rumus: 2 * (3,14 * jari-jari)
Program java :
import javax.swing.JOptionPane;
public class kellingkaran
{
public static void main(String args[])
{
String first;int number1;int sum;
first=JOptionPane.showInputDialog("Masukkan jari-jari lingkaran");
number1=Integer.parseInt(first);
sum=2*22/7*number1;
JOptionPane.showMessageDialog(null,"keliling lingkaran adalah: "+sum,"Hasil",JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}
8.Menghitung Luas Segitiga rumus: alas * tinggi / 2
Program java :
import javax.swing.JOptionPane;
public class luassegitiga
{
public static void main(String args[])
{
String first;String second;int number1;int number2;int sum;
first=JOptionPane.showInputDialog("Masukkan alas");
second=JOptionPane.showInputDialog("Masukkan tinggi");
number1=Integer.parseInt(first);
number2=Integer.parseInt(second);
sum=number1*number2/2;
JOptionPane.showMessageDialog(null,"Luas segitiga adalah"+sum,"Hasil",JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}
9. Menghitung Volume Balok rumus: panjang * lebar * tinggi
Program java :
import javax.swing.JOptionPane;
public class balok
{
public static void main(String args[])
{
String first;String second;String third;String fourth;int number1;int number2;int number3;int sum;
first=JOptionPane.showInputDialog("Masukkan panjang :");
second=JOptionPane.showInputDialog("Masukkan lebar :");
third=JOptionPane.showInputDialog("Masukkan tinggi :");
number1=Integer.parseInt(first);
number2=Integer.parseInt(second);
number3=Integer.parseInt(third);
sum=number1*number2*number3;
JOptionPane.showMessageDialog(null,"Volume balok adalah : "+sum,"Hasil",JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}
package com.pbo.java;
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;
}
}
}