Contoh Program mencari Luas Persegi Panjang Dengan Bahasa Pemrograman Java
import java.util.Scanner;
public class RectArea {
static void ReadPL(){
System.out.println("In Procedure
ReadPL..");
}
static void WritePL(Float W, Float L){
System.out.println("In Procedure WritePL..");
System.out.println("Width= "+W);
System.out.println("Length= "+L);
}
static
Float AreaRect(Float W, Float L){
return W*L;
}
public
static void main(String[] args) {
float width, length, height;
Scanner sc= new Scanner(System.in);
ReadPL();
System.out.print("Width= ");width=sc.nextFloat();
System.out.print("Length= ");length=sc.nextFloat();
WritePL(width,length);
// hitung keliling
System.out.println("Luas rectangle =
"+AreaRect(width,length));
System.out.print("Height= ");height=sc.nextFloat();
// hitung volume
}
}