URI Problem (Area) 1012 Solution in Java

Problem Solving, URI

URI Problem (Area) 1012:
Area is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @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);
    }
}

0 Comments

You may find interest following article

Chapter 4 Relational Algebra

Relational Algebra The part of mathematics in which letters and other general symbols are used to represent numbers and quantities in formula and equations. Ex: (x + y) · z = (x · z) + (y · z). The main application of relational algebra is providing a theoretical foundation for relational databases, particularly query languages for such databases. Relational algebra...

Chapter 3 Components of the Database System Environment

Components of the Database System Environment There are five major components in the database system environment and their interrelationships are. Hardware Software Data Users Procedures Hardware:  The hardware is the actual computer system used for keeping and accessing the database. Conventional DBMS hardware consists of secondary storage devices, usually...