daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Feb 22nd, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2. public class Q4
  3. {
  4.     public static void main(String[] args)
  5.     {
  6.      Scanner in = new Scanner(System.in);
  7.      System.out.println("Circle?");
  8.      System.out.println("Square?");
  9.      System.out.println("Rectangle?");
  10.      System.out.println("Exit?");
  11.      
  12.     String x = in.nextLine();
  13.    
  14.     if (x.equals ("Circle"))
  15.     {
  16.         System.out.print("What is the radius: ");
  17.                 double radius = in.nextDouble();
  18.                 System.out.println("Area is: " + Math.PI * Math.pow(radius, 2));
  19.     }
  20.                 else
  21.     if (x.equals ("Square"))
  22.     {
  23.      System.out.print ("What is the length: ");
  24.      double length = in.nextDouble();
  25.      System.out.println ("Area is: " + length * length);
  26.     }
  27.                 else
  28.         if (x.equals ("Rectangle"))
  29.         {
  30.             System.out.print ("What is the length: ");
  31.             double length2 = in.nextDouble();
  32.             System.out.print ("What is the width: ");
  33.             double width = in.nextDouble();
  34.             System.out.println ("Area is: " + length2 * width);
  35.         }
  36.     else
  37.             if (x.equals ("Exit"))
  38.             {
  39.                 System.out.println("Exit.");
  40.         }
  41.     }
  42. }
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