Advertisement
vencinachev

Untitled

Nov 13th, 2019
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class App2 {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         System.out.println("Enter type on shape !");
  7.         String shape = scan.next();
  8.         if(shape.equals("square")){
  9.             System.out.println("Enter side on square");
  10.             double side = scan.nextDouble();
  11.             double result = side * side;
  12.             System.out.println("S = " + result);
  13.         }else if(shape.equals("rectangle")){
  14.             System.out.println("Enter side one on rectangle");
  15.             double side1 = scan.nextDouble();
  16.             System.out.println("Enter side two on rectangle");
  17.             double side2 = scan.nextDouble();
  18.             double result = side1 * side2;
  19.             System.out.println(result);
  20.         }else if(shape.equals("circle")){
  21.             System.out.println("Enter radius ");
  22.             double radius = scan.nextDouble();
  23.             //double result = 3.14 * radius * radius;
  24.             double result = Math.PI * radius * radius;
  25.             System.out.printf("s = %.2f",result);
  26.             System.out.println("s = " + result);
  27.         }else if(shape.equals("triangle")){
  28.             System.out.println("Enter a:");
  29.             double a = scan.nextDouble();
  30.             System.out.println("Enter b:");
  31.             double b = scan.nextDouble();
  32.             double r = (a * b) / 2;
  33.             System.out.printf("%.2f",r);
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement