* * Copyright (c) 2015, Computer College of Yantai University * All rights reserved. * File name: Test.java * Author: Wang Yuanyang * Completion date: October 13, 2015 * Version number: v1.0 * Problem Description: Enter three values as the triangular three sides, to determine whether the triangle can be formed, if you can find the triangle
of the area * * Import Java.util.Scanner; public class Mytrian {/** * @param args */public static void main (string[] args) {//TODO auto-generated Metho
D stub Scanner input = new Scanner (system.in);
System.out.println ("Enter three sides of the Triangle in decimal:");
Double A = input.nextdouble ();
Double b = input.nextdouble ();
Double c = input.nextdouble ();
Boolean X=isvalid (A, B, c);
if (x==true) System.out.println ("This triangle can be built to and its" are: "+area (A,b,c));
else System.out.println ("This triangle cannot to be built!"); public static Boolean IsValid (double side1, double side2, double side3) {if (Side1 + side2-side3>0 &&
Side1 + side3-side2>0 && side2 + side3-side1 > 0) return true;
else return false;
}
public static double area (double side1, double side2, double side3) {double p = (side1 + side2 + side3)/2;
Return Math.sqrt (P * (p-side1) * (p-side2) * (P-SIDE3));
}
}