### how to display inputed values

Program works perfectly fine. I input in the length, width and height. But i want it to display those values for every individual prism when i output... along with the area and volume which i already have. Since i made a vector i won't let me cout it normally.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166`` ``````#include #include using namespace std; class Rectangle{ public: Rectangle(); void setLength(double length){ l=length; } void setWidth(double width){ w=width; } void setHeight(double height){ h=height; } double getArea(double sa);//Surface Area double getVolume(double v); void dispaly(); private: double l; double w; double h; double sa, v; }; vectorord; Rectangle::Rectangle() { l=0; w=0; h=0; } double Rectangle::getArea(double sa){ sa=2*(w*h+l*w+l*h); return sa; } double Rectangle::getVolume(double v){ v=l*w*h; return v; } int main(){ double length, width, height; double sa, v; int count=0; int h; Rectangle p; do{ cout<<"Enter you length: "; cin>>length; p.setLength(length); cout<<"Enter your width: "; cin>>width; p.setWidth(width); cout<<"Enter your height: "; cin>>height; p.setHeight(height); cout<<"\n"; ord.push_back(p); count++; }while (count<5); for(int i = 0; i < count; i++){ for (int m = count-1; m > 0; m--) { for (int n = 0; n < m; n++) { if (ord[n].getVolume(v) > ord[n+1].getVolume(v)) { Rectangle temp = ord[n]; ord[n] = ord[n+1]; ord[n+1] = temp; } } } cout<<"SA: "<
Last edited on
nvm fixed it just changed private variables and made them public
Last edited on
double sa, v; at line 95 are being used without having been initialized. Meaning there is garbage value stored in these two variables.
At line 98: No use of h.
Topic archived. No new replies allowed.