Program Pengukuran Luas

Posted: September 20, 2012 in Pemrograman, TugasPBO

import java.util.Scanner;

public class train {
public static void main(String[] args) {

Scanner stdin = new Scanner(System.in);
System.out.println(“\n==== Program Pengukuran Luas ====”);

int a=1;
do{
System.out.println(“\n\n== Pilihan :  ==”);
System.out.println(“1 : Luas Persegi”);
System.out.println(“2 : Luas Persegi Panjang”);
System.out.println(“3 : Luas Segitiga”);
System.out.println(“4 : Keluar”);
System.out.print(“\nPilihan Anda : “);

int pilihan= stdin.nextInt();
switch(pilihan) {
case 1 :
Scanner coba = new Scanner(System.in);
int sasa, sisi;
System.out.print(“Masukkan nilai a : “);
sasa = coba.nextInt();
System.out.print(“Masukkan nilai b : “);
sisi = coba.nextInt();
int luaspersegi=sasa*sisi;

System.out.println(“Luas Persegi Adalah : ” +luaspersegi);
break;
case 2 :
Scanner coba2 = new Scanner(System.in);
int panjang, lebar;
System.out.print(“Masukkan Nilai Panjang : “);
panjang = coba2.nextInt();
System.out.print(“Masukkan Nilai Lebar : “);
lebar = coba2.nextInt();
int luas=panjang *lebar;

System.out.println(“Luas Persegi Panjang Adalah : “+luas);

break;
case 3 :
Scanner coba3 = new Scanner (System.in);
int alas, tinggi;
System.out.print(“Masukkan Panjang Alas : “);
alas = coba3.nextInt();
System.out.print(“Masukkan Panjang Tinggi : “);
tinggi = coba3.nextInt();
double segitiga =0.5 * alas * tinggi;
System.out.println(“Luas Segitiga Adalah : “+segitiga);
break;
case 4 :
System.exit(0);
break;
default:System.out.print(“Pilihan Salah!”);
}
}
while(a==1);
}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s