Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
1.2k views
in Computer by (45.3k points)
closed by

Write the definition of a class CONTAINER in C++ with the following description: 

Private Members

 – Radius, Height // float 

– Type //int (1 for Cone, 2 for Cylinder) 

– Volume // float 

– CalVolume() // Member function to calculate 

// volume as per the Type

Public Members 

– GetValues() 

// A function to allow user to enter value 

// of Radius, Height and Type. Also, call 

// function CalVolume () from it

 – ShowAll () 

// A function to display Radius, Height, 

// Type and Volume of Container

1 Answer

+1 vote
by (50.9k points)
selected by
 
Best answer

class CONTAINER

{

float Radius, Height, Volume;

int Type;

void Cal Volume()

{

if(Type ==1)

Volume = 3.14* Radius * Height;

else if (Type =2)

Volume = 3.14* Radius * Height/3;

else

Volume =0;

}

public;

void GetValues()

{

cout<<"\n Enter the Radius"; cin>>Radius;

cout<<"\n Enter the Height"; cin>>Height;

cout<<"\n Enter the Type (1 for Cone, 2 for Cylinder)";

cin>>>Type;

CalVolume();

}

void ShowAll()

{

cout<<"\n Radius :"<<Radius;

cout<<"\n Height:"<<Height;

cout<<"\n Type :"< cout<<"\n Volume:"<<Volume;

}

};

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...