Print a box
1. Write a java program Shape, in the main method asks the user to enter a positive odd number less than 20, greater than 2.
1) If the number is 5, 11 or 15, create a square, print the box and calculate the area of the square,
2) if 3, 9, or 17,create a rectangle with length is the number times 2, and the number is the height; print a rectangle box and calculate the area of the rectangle,
3) With all the other odd numbers, create a right triangle, with the base is the number and the height is the base + 3 , print the triangle box and calculate the area.
4) A validation method to validate the input.
2. Write a class of Shape with a constructor.
1) a constructor (default one).
2)a method of drawing() -- print out the message " In Shape instance.".
3. Write a class of Square extends Shape
1) a private variable side as int type;
2) a constructor with side passed in;
3) a method of calculateArea(int side) -- return the area of square as side*side.
4) a method of drawing(int side) -- print a square box;
4. Write a class of Rectangle extends Shape
1) 2 private variables length and width as int type;
2) a constructor with width passed in and calculate the length as width*2;
3) a method of calculateArea(int length, int width) -- return the area of rectangle as length*width.
4) a method of drawing(int length, int width) -- print a rectangle box;
5. Write a class of Triangle extends Shape
1) 2 private variables base and height as int type;
2) a constructor with base passed in and the height is the base+3;
3) a method of calculateArea(int side) -- return the area of triangle as base*height/2.
4) a method of drawing(int base, int height) -- print a triangle box;
Note: You will need submit Shape.java, Square.java, Rectangle.java and Triangle.java files.