題目
輸入長寬高求其週長與面積
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);
}
}
留言列表