daily pastebin goal
31%
SHARE
TWEET

area figures

pproxidevengwess Mar 26th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.         String input = scanner.nextLine();
  10.         double area = 0;
  11.         if ("square".equals(input)) {
  12.             double side = Double.parseDouble(scanner.nextLine());
  13.             area = side*side;
  14.         } else if ("ractangle".equals(input)) {
  15.             double a = Double.parseDouble(scanner.nextLine());
  16.             double b = Double.parseDouble(scanner.nextLine());
  17.             area = a * b;
  18.         } else if ("circle".equals(input)) {
  19.             double r = Double.parseDouble(scanner.nextLine());
  20.             area = Math.PI * r * r;
  21.         } else if ("triangle".equals(input)) {
  22.             double a = Double.parseDouble(scanner.nextLine());
  23.             double b = Double.parseDouble(scanner.nextLine());
  24.             area = (a*b)/2;
  25.         }
  26.         System.out.printf("%.3f", area);
  27.  
  28.     }
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top