Question: (java) please try quickly thank you Volume = (1/3) X base? x height Surface Area = 2 X base X Slant + base? b Question-1
Volume = (1/3) X base? x height Surface Area = 2 X base X Slant + base? b Question-1 (100 Points) 1. Create a class named SquarePyramid. 2. The class has three attributes, base, slant, and height. All attributes are set to 1 in the default constructor. The attributes should only be visible in the class. 3. Create another fully parameterized constructor that takes the all attributes as parameters. 4. Provide set and get methods for all attributes. The set methods should verify that the values are positive. Never allow negative values for any attribute. 5. Provide two methods to calculate the surface area and the volume of the square pyramid according to the formulas shown above. 6. Provide a utility method (getDetails) that returns a formatted string about the details of the Cone object. It should print the base, slant, height, surface area, and volume each in a separate line with a proper message. All values should be set to two decimal places. See sample output Pyramid Base = 3.90, Height 5.60, Slant - 7.80 Surface Area = 76.05 Volume = 28.39 7. Write a tester program to test the SquarePyramid class. a. Create two different objects in it. Use a different constructor for each of them. Set their parameters. b. Print the details of both objects
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
