import java.util.Scanner; public class LuasPersegiPanjang { public static void main (String [] args) { Scanner nilai = new Scanner(System.in); int min,max; System.out.print("nilai minimal = "); min = nilai.nextInt(); System.out.print("nilai maksimal = "); max = nilai.nextInt(); if (max < min) { System.out.println("nilai maksimal harus lebih besar dari nilai minimal = "); System.out.print("nilai maksimal = "); max = nilai.nextInt(); } double panjang = min + Math.random () * (max - min + 1); double lebar = min + Math.random () * (max - min + 1); panjang = (int)panjang; lebar = (int)lebar; System.out.println("Luas Persegi panhang = Panjang x lebar"); System.out.println("\t\t =" +((int)panjang)+" x "+((int)lebar)); System.out.println("\t\t ="+((int)(panjang * lebar))); } }
program mencari luas persegi panjang dengan java
January 18, 2014
Bobby Syahronanda
0 Comments