第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

編寫應(yīng)用程序,創(chuàng)建類的對象,分別設(shè)置圓的半徑、圓柱體的高,并求出圓柱體的體積。

編寫應(yīng)用程序,創(chuàng)建類的對象,分別設(shè)置圓的半徑、圓柱體的高,并求出圓柱體的體積。

諤螺絲 2016-01-02 17:52:23
/* 編寫一個圓柱體類Cylinder,擁有:?@兩個成員變量? double h(私有,浮點(diǎn)); ?//圓柱體的高;? double r(私有,浮點(diǎn)); ?//圓柱體的半徑;??@構(gòu)造方法? Cylider(double r,double h) //創(chuàng)建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();//編譯顯示以下兩句有錯,去掉后最后的結(jié)果多了一個。 ? ? ? ? Cylinder b1=new Cylinder(); ? ? ? ? b1.getVolume();? ? ? ??? ? ? ? Cylinder b2=new Cylinder(); ? ? ? ? b2.showVolume();? ? }}
查看完整描述

3 回答

已采納
?
產(chǎn)品經(jīng)理不是經(jīng)理

TA貢獻(xiàn)481條經(jīng)驗 獲得超143個贊

你沒傳參數(shù)進(jìn)去?? b1.getVolume(???);

查看完整回答
1 反對 回復(fù) 2016-01-02
?
產(chǎn)品經(jīng)理不是經(jīng)理

TA貢獻(xiàn)481條經(jīng)驗 獲得超143個贊

? Cylinder b1=new Cylinder();

?Cylinder b2=new Cylinder();

這兩句話各打印了一次結(jié)果

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

TA貢獻(xiàn)2條經(jīng)驗 獲得超0個贊

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

有4個結(jié)果,不是只有兩個嗎?

查看完整回答
反對 回復(fù) 2016-01-02
  • 3 回答
  • 0 關(guān)注
  • 2958 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號