Wednesday, March 30, 2016

URI 1043 Solution in java language || Triangle

View the main link :
https://www.urionlinejudge.com.br/judge/en/problems/view/1043


URI Online Judge | 1043

Triangle

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read three point floating values (A, B and C) and verify if is possible to make a triangle with them. If it is possible, calculate the perimeter of the triangle and print the message:

Perimetro = XX.X

If it is not possible, calculate the area of the trapezium which basis A and B and C as height, and print the message:

Area = XX.X


Input

The input file has tree floating point numbers.

Output

Print the result with one digit after the decimal point.
Input SampleOutput Sample
6.0 4.0 2.0Area = 10.0
6.0 4.0 2.1Perimetro = 12.1


URI 1043 Solution in Java language:


package URI_Problems_solution; /** 6.0 4.0 2.0 Area = 10.0 6.0 4.0 2.1 Perimetro = 12.1 */ import java.util.Scanner; public class URI_1043 { public static void main(String[] args) { float A, B, C, areaTraphisium, perimeterTriangle ; Scanner input =new Scanner(System.in); A = input.nextFloat(); B = input.nextFloat(); C = input.nextFloat(); if ((A < (float)(B+C)) && (B < (float)(A+C)) && (C < (float)(B+A))) { //Triangle perimeter = a + b + c; //Traphisium area is = (a + b)*h/2 perimeterTriangle = A + B + C; System.out.printf("Perimetro = %.1f\n",perimeterTriangle); }else { areaTraphisium = ((A + B) * C) / 2; System.out.printf("Area = %.1f\n",areaTraphisium); } } }


No comments:
Write comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.