Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- * Created by Atanas on 17/01/2017.
- */
- public class p13_Sharea {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String shape = scanner.nextLine();
- if (shape.equals("square")){
- double a = Double.parseDouble(scanner.nextLine());
- double b = a * a;
- System.out.printf("%.3f%n", b);
- } else if (shape.equals("circle")){
- double a = Double.parseDouble(scanner.nextLine());
- double b = a * a * Math.PI;
- System.out.printf("%.3f%n", b);
- } else if (shape.equals("rectangle")){
- double a = Double.parseDouble(scanner.nextLine());
- double b = Double.parseDouble(scanner.nextLine());
- double c = a * b;
- System.out.printf("%.3f%n", c);
- } else if (shape.equals("triangle")){
- double a = Double.parseDouble(scanner.nextLine());
- double b = Double.parseDouble(scanner.nextLine());
- double c = (a * b) / 2;
- System.out.printf("%.3f%n", c);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement