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 _13a_AreaOfFigures
- {
- public static void main(String[] args)
- {
- Scanner scan = new Scanner(System.in);
- String figure = scan.nextLine().toLowerCase();
- double area = 0d;
- if (figure.equals("square"))
- {
- area = Math.pow(Double.parseDouble(scan.nextLine()), 2);
- }
- else if (figure.equals("rectangle"))
- {
- double a = Double.parseDouble(scan.nextLine());
- double b = Double.parseDouble(scan.nextLine());
- area = a * b;
- }
- else if (figure.equals("circle"))
- {
- area = Math.pow(Double.parseDouble(scan.nextLine()), 2) * Math.PI;
- }
- else if (figure.equals("triangle"))
- {
- double c = Double.parseDouble(scan.nextLine());
- double h = Double.parseDouble(scan.nextLine());
- area = c * h / 2d;
- }
- System.out.printf("%.3f", area);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment