Skip to content

Statement:Anil very well knows the power of object orientation so he wants to create a small program that can calculate the volume of a water tank. He knows, he can calculate the volume of any shape if the length L, width W and height H of that shape is known. But he also knows rather focusing on length, width and height if any one provides a wa…

Notifications You must be signed in to change notification settings

nitesh-30/calculate-volume-of-water-tank

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

calculate-volume-of-water-tank

Statement:Anil very well knows the power of object orientation so he wants to create a small program that can calculate the volume of a water tank. He knows, he can calculate the volume of any shape if the length L, width W and height H of that shape is known. But he also knows rather focusing on length, width and height if any one provides a water tank to his program still, he can calculate the volume using object-oriented way. In order to achieve his goal, he needs your help to create such program which should be smart enough to calculate the volume in following conditions. If any one gives only one number x to calculate the volume your program should treat L=B=H=x And calculate the volume. If any one gives only two numbers x and y to calculate the volume your program should treat L=B=x and H=y If any one gives three numbers x,y and z then treat 3 numbers as x=L, y=B and z=H respectively. Now interesting thing is if any one gives a WaterTank your program should able to find given water tank’s L B and H and calculate volume of it. to implement the above operations create a class Calculate and create function volume(<arguments>) inside that class, to calculate volume for all above cases and finally print the calculated volume in the volume(<arguments>)function only. in order to create the watertank object first design a class WaterTank which contains 3 private data members L B and H of type integer. class WaterTank contains following methods. first it contains a constructor, the constructor work is to accept three integers as argument and initialize instance variable L, B and H with these arguments. class WaterTank contains 3 more methods getLength(), getWidth() and getHeight() work of these functions is to return value of L, B and H respectively. for better understating we are providing you a code snippet, this code snippet contains a main() method and some statements. We have already written this code snippet in this program so there is no need to write main() method for this program. So your task is to just observer the code snippet and write the rest code (class creation) which is required for successful execution of the program. int main() { int x,y,z; //declaring three variables x,y and z denoting length, width and height respectively. int l,b,h;//declaring three variables l,b and h denoting length, width and height of WaterTank object respectively. cin>>x>>y>>z; //taking input in x, y and z denoting length, width and height of tank respectively. cin>>l>>b>>h;//taking input in l, b and h denoting length, width and height of WaterTank Object respectively. WaterTank w(l,b,h);//creating object w of WaterTank Calculate c;//creating object c of Calculate class c.volume(x);//should print the volume by assuming length=width=height=x c.volume(x,y); //should print the volume by assuming length=width=x and height=y c.volume(x,y,z);//should print the volume by assuming length=x, width=y and height=z c.volume(w);//should print the volume of watertank w. return 0; } Input:first line contains three integers x, y and z denoting length, width and height respectively. second line contains three integers l, b and h denoting length, width and height of watertank object respectively. Output:output contains four lines. first line contains an integer denoting volume by assuming length=width=height=x second line contains an integer denoting volume by assuming length=width=x and height=y third line contains an integer denoting volume by assuming length=x, width=y and height=z fourth line contains an integer denoting volume of watertank w. Constraint :1<=all variables<=50 don’t write main() method in your program, just complete the coding of class. include header files and use namespaces as per your requirement.

About

Statement:Anil very well knows the power of object orientation so he wants to create a small program that can calculate the volume of a water tank. He knows, he can calculate the volume of any shape if the length L, width W and height H of that shape is known. But he also knows rather focusing on length, width and height if any one provides a wa…

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages