Java Area of ​​Rhombus App (JARA)


JARA:   SOLD       




The Rhombus program has variable declarations d1 (which is diagonal 1), and, d2 (which is diagonal 2), and lu (which is the result of the formula/area). These three variables have a double data type because there is a possibility that the result or value given is in fractional form.

The BelahKetupat program also has a constructor method with parameters double diagonal1, and, double diagonal2. This constructor method is used to store values ​​in each variable.

The lu method is used to calculate the area of ​​a rhombus with the syntax double lu=d1*d2*0.5;

Code:

import java.util.Scanner;
/** * * @author HP */
public class PBO {
  /** * @param args the command line arguments */
  public static void main(String[] args) {
    Scanner ketupat = new Scanner(System. in );
    System.out.print("\n...:: Mencari Luas Belah Ketupat::...\n");
    System.out.print("masukan nilai diagonal1: ");
    double d1 = ketupat.nextDouble();
    System.out.print("masukan nilai diagonal2: ");
    double d2 = ketupat.nextDouble();
    double lu = d1 * d2 * 0.5;
    System.out.print("maka luas belah ketupat adalah:" + lu);
    System.out.println("");
  }
}

Post a Comment

Previous Next

نموذج الاتصال