SHARE
TWEET

Untitled

a guest Nov 11th, 2019 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Ex1Triangle {
  2.  
  3.     public static void main(String[] args) {
  4.         System.out.println("Enter three sides ");
  5.         Scanner scanner = new Scanner(System.in);
  6.         double side1 = scanner.nextDouble();
  7.         double side2 = scanner.nextDouble();
  8.         double side3 = scanner.nextDouble();
  9.         System.out.println("Enter the color: ");
  10.         String color = scanner.next();
  11.         System.out.println("Enter a boolean value for filled: ");
  12.         boolean fill = scanner.hasNextBoolean();
  13.        
  14.         Triangle triangle = new Triangle(side1, side2, side3); 
  15.         triangle.setColor(color);
  16.         triangle.setFilled(fill);
  17.         System.out.println(triangle.toString());
  18.         System.out.println("The area is " + triangle.getArea());
  19.         System.out.println("The perimeter is " + triangle.getPerimeter());
  20.         System.out.println("color: " + triangle.getColor());
  21.         System.out.print(triangle.toString());
  22.         String x = "";
  23.         if (triangle.isFilled()) {
  24.             x = "filled";
  25.         }
  26.         else {
  27.             x = "not filled";
  28.         }
  29.         System.out.println(" Triangle is " + color + " and " + x);
  30.  
  31.     }
  32.  
  33. }
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