過去に作成した円周・面積・体積を求めるプログラムに、
表面積を求めるサブクラスを作成したのですが、
表面積は「~cm2です」という表示がされません。
何が問題なのでしょうか?
ご回答よろしくお願いいたします。
class
1 double R; 2 radius(double p){ 3 R=p; 4 5 } 6 void showPrice(){ 7 float total0=(float)(2*Math.PI*R); 8 float total1=(float)(Math.PI*Math.pow(R,2.0)); 9 float total2=(float)(4.0/3*Math.PI*Math.pow(R,3.0)); 10 System.out.println("円周は "+total0+" cm."); 11 System.out.println("面積は "+total1+" cm2."); 12 System.out.println("体積は "+total2+" cm3."); 13 } 14} 15スーパークラス
class
1 Surface(double p){ 2 super(p); 3 } 4 void showPrice(){ 5 float surface=(float)(4*Math.PI*Math.pow(R,2.0)); 6 System.out.println("表面積は "+Surface+" cm2"); 7 } 8 public static void main(String[] args){ 9 radius a=new radius(12.3); 10 11 a.showPrice(); 12 } 13} 14サブクラス
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/01/20 06:58