Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- double area = 0;
- if ("square".equals(input)) {
- double side = Double.parseDouble(scanner.nextLine());
- area = side*side;
- } else if ("ractangle".equals(input)) {
- double a = Double.parseDouble(scanner.nextLine());
- double b = Double.parseDouble(scanner.nextLine());
- area = a * b;
- } else if ("circle".equals(input)) {
- double r = Double.parseDouble(scanner.nextLine());
- area = Math.PI * r * r;
- } else if ("triangle".equals(input)) {
- double a = Double.parseDouble(scanner.nextLine());
- double b = Double.parseDouble(scanner.nextLine());
- area = (a*b)/2;
- }
- System.out.printf("%.3f", area);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement