URI Problem 1012 Solution in Java
Problem Details Link
Solution:
Solution:
import java.util.Scanner;
/**
* @Author : Muhammad Harun-Or-Roshid
* @E-mail : md.parvez28@gmail.com
* @Date : Oct 6, 2016
* @Time : 8:38:17 PM
*/
public class Uri1012 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double A,B,C;
A = sc.nextDouble();
B = sc.nextDouble();
C = sc.nextDouble();
//a) the area of the rectangled triangle that has base A and height C.
double area_triangle = 0.5f*A*C;
//b) the area of the radius's circle C. (pi = 3.14159)
double area_radius = 3.14159*C*C;
//c) the area of the trapezium which has A and B by base, and C by height.
double area_trapezium = ((A+B)/2)*C;
//d) the area of the square that has side B.
double area_square = B*B;
//e) the area of the rectangle that has sides A and B.
double area_rectangle = A*B;
System.out.printf("TRIANGULO: %.3f\n",area_triangle);
System.out.printf("CIRCULO: %.3f\n",area_radius);
System.out.printf("TRAPEZIO: %.3f\n",area_trapezium);
System.out.printf("QUADRADO: %.3f\n",area_square);
System.out.printf("RETANGULO: %.3f\n",area_rectangle);
}
}
Comments
Post a Comment