menghitung luas trapesium dengan java
Menghitung trapesium.
Code:
import java.io.*;
class trapesium{
public static void main(String[] args)
throws Exception{
float sisi1 = 0; float sisi2 = 0;
float tinggi= 0; float luas = 0;
DataInputStream dis = new
DataInputStream(System.in);
System.out.print("Nilai Sisi A \t\t: ");
sisi1 = Float.parseFloat(dis .readLine());
System.out.print("Nilai Sisi Sisi B \t: ");
sisi2 = Float.parseFloat(dis .readLine());
System.out.print("Nilai Tinggi \t\t: ");
tinggi= Float.parseFloat(dis .readLine());
luas = ((sisi1 + sisi2) * tinggi)/2;
System.out.println
("---------------------------");
System.out.println("| LUAS BANGUNAN
TRAPESIUM |");
System.out.println
("===========================");
System.out.println("| Nilai sisi A\t :" +
sisi1);
System.out.println("| Nilai sisi B\t :" +
sisi2);
System.out.println("| Nilai tinggi\t :" +
tinggi);
System.out.println("| Luas trapesium
\t :" + luas);
System.out.println
("---------------------------"); } }
Code:
import java.io.*;
class trapesium{
public static void main(String[] args)
throws Exception{
float sisi1 = 0; float sisi2 = 0;
float tinggi= 0; float luas = 0;
DataInputStream dis = new
DataInputStream(System.in);
System.out.print("Nilai Sisi A \t\t: ");
sisi1 = Float.parseFloat(dis .readLine());
System.out.print("Nilai Sisi Sisi B \t: ");
sisi2 = Float.parseFloat(dis .readLine());
System.out.print("Nilai Tinggi \t\t: ");
tinggi= Float.parseFloat(dis .readLine());
luas = ((sisi1 + sisi2) * tinggi)/2;
System.out.println
("---------------------------");
System.out.println("| LUAS BANGUNAN
TRAPESIUM |");
System.out.println
("===========================");
System.out.println("| Nilai sisi A\t :" +
sisi1);
System.out.println("| Nilai sisi B\t :" +
sisi2);
System.out.println("| Nilai tinggi\t :" +
tinggi);
System.out.println("| Luas trapesium
\t :" + luas);
System.out.println
("---------------------------"); } }
0 komentar:
terima kasih atas kunjungan anda
http://tugasbloger.blogspot.com/