#include <iostream>
using namespace std;
class Bulk
{
public:
void get_value();
void display();
private:
float lengh;
float width;
float height;
};
void Bulk::get_value()
{
cout<<"請輸入長、寬、高:";
cin>>lengh;
cin>>width;
cin>>height;
}
void Bulk::display()
{
cout<<"體積爲: "<<lengh*width*height<<endl;
cout<<"表面積爲: "<<2*(lengh*width+lengh*height+width*height)<<endl;
}
int main()
{
Bulk b1,b2,b3;
b1.get_value();
cout<<"第一個長方柱: "<<endl;
b1.display();
b2.get_value();
cout<<"第二個長方柱: "<<endl;
b2.display();
b3.get_value();
cout<<"第三個長方柱: "<<endl;
b3.display();
return 0;
}
第三週 任務四
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.