volume of shapes using class and operator overload
#include <iostream>
#include <iomanip>
using namespace std;
class cuboidvolume{
float l,b,h;
float r;
float rc,rh;
public:
void v(float l, float b, float h){
std::cout << std::fixed << std::setprecision(2);
float vol=l*b*h;
if (vol < 1){
std::cout << "Less volume:Data not sufficient\n";
}
else{
std::cout << vol << '\n';
}
}
void v(float r){
std::cout << std::fixed << std::setprecision(2);
float fourbythree=4.0/3.0;
float vol=fourbythree*(3.14)*r*r*r;
if (vol < 1){
std::cout << "Less volume:Data not sufficient\n";
}
else{
std::cout << vol << '\n';
}
}
void v(float rc, float hc){
std::cout << std::fixed << std::setprecision(2);
float vol=(3.14)*rc*rc*hc;
if (vol < 1){
std::cout << "Less volume:Data not sufficient\n";
}
else{
std::cout << vol << '\n';
}
}
};
int main(){
float l,b,h;
float r;
float rc,hc;
cin>>l>>b>>h;
cin>>r;
cin>>rc>>hc;
cuboidvolume x;
x.v(l,b,h);
x.v(r);
x.v(rc,hc);
return 0;
}