import javax.swing.*;

public class ProvaTriangoli {
  public static void main(String[] args) {
    String stringaInput;
    stringaInput = JOptionPane.showInputDialog("Scegli il LATO 1");
    double l1 = Double.parseDouble(stringaInput);
    stringaInput = JOptionPane.showInputDialog("Scegli il LATO 2");
    double l2 = Double.parseDouble(stringaInput);
    stringaInput = JOptionPane.showInputDialog("Scegli il LATO 3");
    double l3 = Double.parseDouble(stringaInput);
    
    Triangolo mioTriangolo = new Triangolo(l1,l2,l3);
    if(mioTriangolo.isValido()) 
      JOptionPane.showMessageDialog(null, "L'area del triangolo  " +
        mioTriangolo.getArea() + "\ne il perimetro  " + mioTriangolo.getPerimetro());
    else    
      JOptionPane.showMessageDialog(null, "Triangolo NON valido");
    
    System.exit(0);
  }
}

class Triangolo {
  double lato1, lato2, lato3;
  
  public Triangolo() {
    this.lato1 = this.lato2 = this.lato3 = 1;
  }
  
  public Triangolo(double l1, double l2, double l3) {
    this.lato1 = l1;
    this.lato2 = l2;
    this.lato3 = l3;
  }
  
  public double getLato1() {
    return this.lato1;
  }

  public double getLato2() {
    return this.lato2;
  }

  public double getLato3() {
    return this.lato3;
  }

  public void setLato1(double x) {
    this.lato1 = x;
  }
  
  public void setLato2(double x) {
    this.lato2 = x;
  }

  public void setLato3(double x) {
    this.lato3 = x;
  }
  
  public boolean isValido() {
    if( (this.lato1+this.lato2>this.lato3) && 
      (this.lato2+this.lato3>this.lato1) &&
      (this.lato3+this.lato1>this.lato2) )
      return true;
    else
      return false;
  }
  
  public double getPerimetro() {
    if(this.isValido()) 
      return this.lato1 + this.lato2 + this.lato3;
    else
      return Double.NaN;
  }
  
  public double getArea() {
    if(this.isValido()) { 
      double p = this.getPerimetro()/2;
      return Math.sqrt(p*(p-this.lato1)*(p-this.lato2)*(p-this.lato3));
    }
    else
      return Double.NaN;
  }
  
}