Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Project: Simple_Conditions - created by borkins on 2017-03-25.
- */
- import java.util.Scanner;
- public class _13b_AreaOfFigures
- {
- public static void main(String[] args)
- {
- Scanner scan = new Scanner(System.in);
- String figure = scan.nextLine().toLowerCase();
- double area = 0d;
- switch (figure)
- {
- case "square":
- area = Math.pow(Double.parseDouble(scan.nextLine()), 2);
- break;
- case "rectangle":
- double a = Double.parseDouble(scan.nextLine());
- double b = Double.parseDouble(scan.nextLine());
- area = a * b;
- break;
- case "circle":
- area = Math.pow(Double.parseDouble(scan.nextLine()), 2) * Math.PI;
- break;
- case "triangle":
- double c = Double.parseDouble(scan.nextLine());
- double h = Double.parseDouble(scan.nextLine());
- area = c * h / 2d;
- break;
- }
- System.out.printf("%.3f", area);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement