Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need assistance solving this problem in C++ while using inheritance and classe

ID: 3783693 • Letter: I

Question

I need assistance solving this problem in C++ while using inheritance and classes. Any help would be greatly appreciated.

Amanda and Tyler opened a business that specializes in shipping liquids, such as milk, juice, and water, in cylinderical containers. The shipping charges depend on the amount of the liquid in the container. (For simplicity, you may assume that the container is filled to the top.) They also provide the option to paint the outside of the container for a reasonable amount. Write a program that does the following: a. Prompts the user to input the dimensions (in feet) of the container (radius of the base and the height). b. Prompts the user to input the shipping cost per liter. c. Prompts the user to input the paint cost per square foot. (Assume that the entire container including the top and bottom needs to be painted.) d. Separately outputs the shipping cost and the cost of painting.

Explanation / Answer

C++ Code:

#include<bits/stdc++.h>
using namespace std;
#define pi 3.141592653589793238
class dimensions
{
   float height;
   float radius;
   public:
       void getdata(float a,float b)
       {
           height=a;
           radius=b;
       }
       float area()
       {
           return ((2*pi*radius*height)+(2*pi*radius*radius));
       }
       float volume()
       {
           return (pi*radius*radius*height);
       }
      
};
class calculate : public dimensions
{
   float scpl;
   float pcsf;
   public:
       void assigndata(float a,float b)
       {
           scpl=a;
           pcsf=b;
       }
       void ShippingAmount()
       {
           cout<<"Shipping Amount is: "<<volume()*(scpl);
       }
       void PaintingAmount()
       {
           cout<<"Painting Amount is: "<<area()*pcsf;
       }
};
int main()
{
   calculate ob1;
   float a,b;
   cout<<"Enter the value of height & radius of cylinder respectively (in foot):";
   cin>>a>>b;
   ob1.getdata(a,b);
   cout<<"Enter the value of Shipping Cost per Litre :";

cin>>a;

cout<<"Enter the value of Painting Cost per Square Foot respectively: ";

cin>>b;
   ob1.assigndata(a,b);
   ob1.ShippingAmount();
   cout<<endl;
   ob1.PaintingAmount();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote