Define the class RectangularCube in C++. A RectangularCube has three sides length(L), width (W), and Height (h), define the sides as private data fields. Include a no-argument constructor that sets all three sides to 1. The class must also have a constructor that receive parameters to initialize sides of the RectangularCube. Include get and set functions for all three data fields. Finally define the functions volume () and surfaceArea () in the class RectangularCube that use the formulas given below to calculate and return the volume and the surface area of the RectangularCube. Give the UML diagram of the class, you may use the MSOffice/Visio to create the UML class diagram (best to download and use Visual paradigm tool, or any other free UML tool). Implement the class using separate files for definition and implementation, use inclusion guard to avoid duplicate code. Make sure to include at least one inline function implementation. Do not Implement the volume () and the SurfaceArea () as inline Include comments in your code. Write a test function for the class RectangularCube and perform the following tasks: Create two objects, one object using the no-argument constructor and another using the constructor with parameters (pick any values for the L, W, and H). Invoke the volume () and SurfaceArea () functions on both object and display their returned value. Invoke a set function on an object and change the value of one of the sides. Invoke the volume () and surfaceArea () functions on the object in part (c) and print their returned values. Assign (using the operator =) and anonymous RectanularCube object to the object in part (c). Once again invoke the volume () and surfaceArea () functions on the object in part (c). Code submission and sample output. In this problem we will continue to expand on the initial problem Write the function with the header void printCube (RectangularCube rc) that receives an object of the type RectangularCube and displays the length, width, height, volume and the surface area of the cube like: L = 2, W = 1, H = 1, V = 2, A = 8. This function should be implemented as a non-member function, meaning that it should be defined outside the class RectangularCube. Write a main function in which you declare an array of 5 RectangularCube objects. Inside the main function, use a loop to initialize/populate this array of RectangularCube. In the body of the loop use the rand () function to generate random integers between 1 and 10 to assign to length, width and height data fields of each RectangularCube object After populating the array, use another loop to display individual elements of the array in part (a) by calling the function printCube in part (a) Code submission and sample output

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Define the class RectangularCube in C++. A RectangularCube has three sides length(L), width (W), and Height (h), define the sides as private data fields. Include a no-argument constructor that sets all three sides to 1. The class must also have a constructor that receive parameters to initialize sides of the RectangularCube. Include get and set functions for all three data fields. Finally define the functions volume () and surfaceArea () in the class RectangularCube that use the formulas given below to calculate and return the volume and the surface area of the RectangularCube.

  1. Give the UML diagram of the class, you may use the MSOffice/Visio to create the UML class diagram (best to download and use Visual paradigm tool, or any other free UML tool).
  2. Implement the class using separate files for definition and implementation, use inclusion guard to avoid duplicate code. Make sure to include at least one inline function implementation. Do not Implement the volume () and the SurfaceArea () as inline Include comments in your code.
  3. Write a test function for the class RectangularCube and perform the following tasks:
    1. Create two objects, one object using the no-argument constructor and another using the constructor with parameters (pick any values for the L, W, and H).
    2. Invoke the volume () and SurfaceArea () functions on both object and display their returned value.
    3. Invoke a set function on an object and change the value of one of the sides.
    4. Invoke the volume () and surfaceArea () functions on the object in part (c) and print their returned values.
    5. Assign (using the operator =) and anonymous RectanularCube object to the object in part (c). Once again invoke the volume () and surfaceArea () functions on the object in part (c).
  4. Code submission and sample output.

In this problem we will continue to expand on the initial problem

  1. Write the function with the header void printCube (RectangularCube rc) that receives an object of the type RectangularCube and displays the length, width, height, volume and the surface area of the cube like: L = 2, W = 1, H = 1, V = 2, A = 8. This function should be implemented as a non-member function, meaning that it should be defined outside the class RectangularCube.
  2. Write a main function in which you declare an array of 5 RectangularCube objects. Inside the main function, use a loop to initialize/populate this array of RectangularCube. In the body of the loop use the rand () function to generate random integers between 1 and 10 to assign to length, width and height data fields of each RectangularCube object
  3. After populating the array, use another loop to display individual elements of the array in part (a) by calling the function printCube in part (a)
  4. Code submission and sample output

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education