亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

編寫應用程序,創建類的對象,分別設置圓的半徑、圓柱體的高,并求出圓柱體的體積。

編寫應用程序,創建類的對象,分別設置圓的半徑、圓柱體的高,并求出圓柱體的體積。

諤螺絲 2016-01-02 17:52:23
/* 編寫一個圓柱體類Cylinder,擁有:?@兩個成員變量? double h(私有,浮點); ?//圓柱體的高;? double r(私有,浮點); ?//圓柱體的半徑;??@構造方法? Cylider(double r,double h) //創建Circle對象時將半徑初始化為r???@成員方法? double getVolume() ?//獲取圓柱體的高? void showVolume() ? //將圓柱體的體積輸出到屏幕*/public class ?Cylinder { private double h=3; ? private double r=2;? ? Cylinder(){? ? ? ? System.out.println(r*r*3.14*h);? ? }? ? double getVolume(double a){? ? ? ? return h;? ? }? ? void showVolume(){? ? ? ? System.out.println(r*r*3.14*h);? ? }? public static void main(String []args){? ? Cylinder ?cylinder=new ?Cylinder();//編譯顯示以下兩句有錯,去掉后最后的結果多了一個。 ? ? ? ? Cylinder b1=new Cylinder(); ? ? ? ? b1.getVolume();? ? ? ??? ? ? ? Cylinder b2=new Cylinder(); ? ? ? ? b2.showVolume();? ? }}
查看完整描述

3 回答

已采納
?
產品經理不是經理

TA貢獻481條經驗 獲得超143個贊

你沒傳參數進去?? b1.getVolume(???);

查看完整回答
1 反對 回復 2016-01-02
?
產品經理不是經理

TA貢獻481條經驗 獲得超143個贊

? Cylinder b1=new Cylinder();

?Cylinder b2=new Cylinder();

這兩句話各打印了一次結果

查看完整回答
1 反對 回復 2016-01-02
?
諤螺絲

TA貢獻2條經驗 獲得超0個贊

為什么輸出結果如下:http://img1.sycdn.imooc.com//5687a573000167b903340123.jpg

有4個結果,不是只有兩個嗎?

查看完整回答
反對 回復 2016-01-02
  • 3 回答
  • 0 關注
  • 2977 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號