Create a class called Cuboid with the data members: length (float), breadth (float) and height (float). Use an inline function and calculate the area of the base using the formula = length * breadth and print it.
Define another member function and calculate the total surface area of the cube using the formula = 2*(length*breadth + breadth*height + height*length) and print it.
Define a friend function to calculate the volume of the cuboid using the formula = length*breadth*height. After calculating the volume, calculate the amount of liquid that can be stored if 1𝑚3 can store 100 liters of liquid.
#include <iostream>
class Cuboid {
private:
float length;
float breadth;
float height;
public:
inline void calculateAreaBase() {
float area = length * breadth;
printf("%f", area);
}
void calculateSurfaceArea() {
float area = 2*(length*breadth + breadth*height + height*length);
printf("%f", area);
}
friend void calculateVolume(Cuboid cuboid);
};
void calculateVolume(Cuboid cuboid) {
float volume = cuboid.length * cuboid.breadth * cuboid.height;
float amountLiquid = volume * 100;
printf("the volume of the cuboid: %f\nthe amount of liquid that can be stored: %f", volume, amountLiquid);
Comments
Leave a comment