JAVA on Machine--5.19__java

Source: Internet
Author: User
* * 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));
 }
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.