Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /*
- * Created by todor on 18.01.2017 г..
- */
- public class u13_AreaOfFigures {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String figure = scan.nextLine().toLowerCase();
- double area = 0;
- switch (figure){
- case "square":
- double squareSide = Double.parseDouble(scan.nextLine());
- area = squareSide * squareSide;
- break;
- case "rectangle":
- double rectangleSideA = Double.parseDouble(scan.nextLine());
- double rectangleSideB = Double.parseDouble(scan.nextLine());
- area = rectangleSideA * rectangleSideB;
- break;
- case "circle":
- double radius = Double.parseDouble(scan.nextLine());
- area = radius * radius * Math.PI;
- break;
- case "triangle":
- double triangleSide = Double.parseDouble(scan.nextLine());
- double triangleHight = Double.parseDouble(scan.nextLine());
- area = (triangleSide * triangleHight) / 2;
- }
- System.out.printf("%.3f", area);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement