Assuming the following class definition:
class Cube {
double side ;
Cube ( ) { side = 0.0; }
Cube ( double side) { this->side = side; }
public double getSide ( ) { return side ; }
public double volume ( ) { return side * side * side ; }
}
1. What change should you make to the above class to ensure data encapsulation is followed and users can create/instantiate an object of the Cube class anywhere in the program?
2. Declare an array of Cube objects. Write code to instantiate 32 Cube objects (using the non-default constructor) whose sides are obtained by using a random generator with LO=1.0 and HIGH=100.0.
3. Use a loop to display all Cube objects' volumes with 2 digits precision and data will be lined up as shown below:
123.45
89.09
4593.16
...........
sorting method that takes the array of Cube objects as its only parameter. The method will sort the array by their volumes in ascending sequence ( 89.09 123.45 4593.16 ..............). HINT: You may use one the sorting methods from the lecture with some modifications.