Answer to Question #346423 in C++ for Nadnivara

Question #346423

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.


1
Expert's answer
2022-05-30T15:14:10-0400
#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);

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS