import java.text.NumberFormat;
import java.util.Locale;
import java.util.Scanner;
public class HargaTanah {
public static double hitungHargaMinimal(double NJOP, double panjang, double lebar) {
double luas = panjang * lebar;
double hargaMinimal = luas * NJOP;
return hargaMinimal;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Meminta input dari pengguna
System.out.print("Masukkan nilai NJOP: ");
double NJOP = scanner.nextDouble();
System.out.print("Masukkan panjang tanah (meter): ");
double panjang = scanner.nextDouble();
System.out.print("Masukkan lebar tanah (meter): ");
double lebar = scanner.nextDouble();
// Memvalidasi input
if (NJOP <= 0 || panjang <= 0 || lebar <= 0) {
System.out.println("Nilai NJOP, panjang, dan lebar harus positif.");
return;
}
// Menghitung harga minimal
double hargaMinimal = hitungHargaMinimal(NJOP, panjang, lebar);
// Format output sebagai mata uang
NumberFormat formatter = NumberFormat.getCurrencyInstance(Locale.getDefault());
String hargaTerformat = formatter.format(hargaMinimal);
System.out.println("Harga jual minimum tanah adalah: " + hargaTerformat);
}
}