In Java, input the length of the three sides of the triangle from the keyboard to judge whether it forms a triangle. If it can, calculate the face of the triangle

In Java, input the length of the three sides of the triangle from the keyboard to judge whether it forms a triangle. If it can, calculate the face of the triangle


//@Author wangfeng
import java.io.InputStreamReader ;
import java.io.BufferedReader ;
public class area {
\x05static InputStreamReader in;
\x05static BufferedReader breader = new BufferedReader(new InputStreamReader( System.in ));
\x05public static boolean judge(int a,int b,int c)
\x05{
\x05\x05int[] array = new int[3];
\x05\x05array[0] = a;
\x05\x05array[1] = b;
\x05\x05array[2] = c;
\x05\x05
\x05\x05for (int i = 0;i < 2; i ++)
\x05\x05{
\x05\x05\x05for (int j = 0; j array[j +1])
\x05\x05\x05\x05{
\x05\x05\x05\x05\x05int temp = array[j];
\x05\x05\x05\x05\x05array[j] = array[j + 1];
\x05\x05\x05\x05\x05array[j + 1]= temp;
\x05\x05\x05\x05}
\x05\x05\x05
\x05\x05}\x05
\x05\x05
\x05\x05if((array[0] + array[1]) > array[2])
\x05\x05\x05
\x05\x05\x05{
\x05\x05\x05 System.out.println (the three sides you enter can form a triangle);
\x05\x05\x05return true;
\x05\x05\x05}
\x05\x05
\x05\x05else
\x05\x05\x05{
\x05\x05\x05 System.out.println ("the three sides you entered cannot form a triangle");
\x05\x05\x05 return false;
\x05\x05\x05}
\x05}
public static void calculate()
{
\x05int array[] = new int [3];
\x05double answer = 0.0;
\x05int p = 0;
\x05try{
\x05for (int i = 0;i < 3; i ++)
\x05\x05{
\x05\x05\x05 System.out.println (please input the "+ (I + 1) +" edge ");
\x05\x05\x05array[i] = Integer.parseInt ( breader.readLine ());
\x05\x05}
\x05}catch(Exception e){};
\x05
\x05if(judge(array[0],array[1],array[2] ) == true)
\x05{
\x05\x05p = (array[0]+ array[1]+array[2])/2;
\x05 answer = Math.sqrt (p * (p - array[0]) * (p - array[1]) * (p - array[2]));
\x05 System.out.println (the area of the triangle formed by the three sides you input is + answer);
\x05}
}
public static void main(String [] argu)
{
\x05calculate();
\x05
}
}



Using java to calculate the area of triangle, rectangle and circle
1) Input the graphic type and parameter value to be calculated through the console, and output the corresponding area
2) Using object-oriented method (encapsulation, inheritance, polymorphism) to develop code
3) Expand and add other types such as trapezoid
4) Use java language, try to use design patterns


//Graphic class as parent class public class diagram {X09 / / calculated area {return 0;}} / / circle class: inherits graphic class public class Crile extensions diagram {x09private double R; < X09 / x09public Crile (double R) {X09 / x09th



We know that in the triangle ABC, the sum of the two sides a + B = 8, ∠ C = 60 degrees, and we can find the maximum value of the area s triangle,


Area ABC = 1 / 2A * b * sin ∠ C = 1 / 2A * b * (3 ^ (1 / 2)) / 2, that is to find the maximum value of a * B, that is a * B



Given the triangle ABC area s = a - (B-C) and B + C = 8, find the maximum ABC area of the triangle and get the help of Da Shen


S = a - (B-C) = a ^ 2-B ^ 2-C ^ 2 + 2BC = - 2BC * cosa + 2BC = 2BC (1-cosa) = 1 / 2 * BC * Sina, so, 2-2cosa = 1 / 2 * Sina, that is, Sina = 4-4cosa, the solution is: Sina = 8 / 17, cosa = 15 / 17, so, s = 1 / 2 * BC * Sina = 4 / 17 * BC ≤ 4 / 17 * [(B + C) / 2] ^ 2 = 64 / 17