Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Nama : Joao da costa

Nim :07052863
Klpk :sn2
Tugas :Prakt.JAVA

Soal
Buatlah program Luas balok dan persegi panjang diinputkan dr keyboard !!!

Jawabannya
 Luas Balok
import java.io.*;
class balok1{
public static void main(String[] args) throws Exception
{
DataInputStream dis = new DataInputStream (System.in);
int p,l,t;
String a,b,c;
double L;
System.out.println("Masukkan Panjang :");
a=dis.readLine();
p=Integer.parseInt(a);
System.out.println("Masukkan Lebar :");
b=dis.readLine();
l=Integer.parseInt(b);
System.out.println("Masukkan Tinggi :"); Hasil Run
c=dis.readLine();
t=Integer.parseInt(c);
L=2*(p+l+t);
System.out.println("Luasnya :"+L);
}
}
 Persegi Panjang

import java.io.*;
class perSegiPanjang
{
public static void main(String[] args) throws Exception
{
DataInputStream dis = new DataInputStream (System.in);
int p,l;
String a,b;
double perSegiPanjang;
System.out.println("Masukkan Panjang :");
a=dis.readLine();
p=Integer.parseInt(a);
System.out.println("Masukkan Lebar :");
b=dis.readLine();
l=Integer.parseInt(b);
perSegiPanjang=p*l;
System.out.println("Hasil Persegi Adalah :"+perSegiPanjang);
}
}

Hasil Run

You might also like