Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Task 1 - Create a class Create a class called cuboid. The class has the attributes ( data members ) length, width and height, each
Task Create a class
Create a class called cuboid. The class has the attributes data members length, width
and height, each of which defaults to It has methods member functions that calculate
the perimeter, surface area and volume of the cuboid. It has set and get functions for
length, width and height. The class in your program should be written based on the class
definition in Listing The cuboid.h file can be downloaded from Ulwazi.
Listing : cuboid.h
#ifndef CUBOIDH
#define CUBOIDH
class cuboid
public: It is good practice to ensure only functions are public members and variables are private
members
cuboiddouble l double w double h ;
void setLengthdouble l; Used to set a user defined vaklue for the length
void setWidthdouble w; Used to set a user defined vaklue for the width
void setHeightdouble h; Used to set a user defined vaklue for the height
double getLength; Used to get the value of the length.
double getWidth; Used to get the value of the width
double getHeight; Used to get the value of height
double perimeter; Used to calculate the perimeter of the cuboid
double surfaceArea; Used to calculate the surface area of the cuboid
double volume; Used to calculate the volume of the cuboid
private: These are private attributes. They can only be accessed using the get and set functions
double length;
double width;
double height;
;
#endif
The program should read from the input.txt shown in Listing For each line in the
input.txt file, the first value represents the length, the second value is the width and the
third value is the height. For example, in the first line the length the width and the
height The other lines in the input text file can be read in the same way. An output
in the form shown in Listing should be generated by your program, where the printed val
ues for the length, width and height are obtained using the getLength getWidth and
getHeight methods functions in the cuboid class. This output should be written to a
file called output.txt
Listing : input.txt
Page of
Listing : output.txt
Length Perimeter
Width Surface Area
Height Volume
Length Perimeter
Width Surface Area
Height Volume
Length Perimeter
Width Surface Area
Height Volume
Length Perimeter
Width Surface Area
Height Volume
Length Perimeter
Width Surface Area
Height Volume
Length Perimeter
Width Surface Area
Height Volume
Length Perimeter
Width Surface Area
Height Volume
Length Perimeter
Width Surface Area
Height Volume
Length Perimeter
Width Surface Area
Height Volume
Length Perimeter
Width Surface Area
Height Volume
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started