題目

輸入長寬高求其週長與面積

package ch4;
import java.io.*;
public class ch4_11_1 
{
    public static void main(String args[]) throws IOException
    {
        int lo,wi,hi,ar,surar;
        String strlo,strwi,strhi;
        InputStreamReader in=new InputStreamReader(System.in);
        BufferedReader buf=new BufferedReader(in);
        System.out.print("請在這邊輸入長:");
        strlo=buf.readLine();
        lo=Integer.parseInt(strlo);
        System.out.println(lo);
        System.out.print("請在這邊輸入寬:");
        strwi=buf.readLine();
        wi=Integer.parseInt(strwi);
        System.out.println(wi);
        System.out.print("請在這邊輸入高:");
        strhi=buf.readLine();
        hi=Integer.parseInt(strhi);
        System.out.println(hi);
        ar=lo*wi*hi;
        System.out.println("四方體體積等於"+ar);
        surar=((lo*wi)+(lo*hi)+(wi*hi))*2;
        System.out.println("四方體表面積等於"+surar);
    }


}
 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 驢子 的頭像
    驢子

    驢子的生活日記

    驢子 發表在 痞客邦 留言(0) 人氣()