鐵之狂傲
標題:
JAVA請會的大大交一下
[列印本頁]
作者:
kingvrf
時間:
06-9-30 23:24
標題:
JAVA請會的大大交一下
import java.io.*;
public class demo4{ //Java 是由類別組成的
public static void main(String args[]) throws Exception
{ //程式進入點
String getbr;
double radius,area;
double pi=3.14159;
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.print("請輸入圓形半徑:");
getbr = br.readLine();
radius=Double.parseDouble(getbr);
area=pi*radius*radius;
System.out.println("圓形面積等於:"+area); //印出字串
}
}
這個程式要怎改才會換變成算梯型面積的阿
請各位大大交一下
作者:
Hunag
時間:
06-10-3 21:13
import java.io.*;
public class trapezoid{
public static void main(String args[]) throws Exception{
String get_up,get_down,get_high;
double t_up,t_down,t_high,trapezoidArea;
double pi=3.14159;
BufferedReader up= new BufferedReader(new InputStreamReader(System.in));
System.out.println("請輸入上底:");
get_up=up.readLine();
BufferedReader down= new BufferedReader(new InputStreamReader(System.in));
System.out.println("請輸入下底:");
get_down=down.readLine();
BufferedReader high= new BufferedReader(new InputStreamReader(System.in));
System.out.println("請輸入高:");
get_high=high.readLine();
t_up=Double.parseDouble(get_up);
t_down=Double.parseDouble(get_down);
t_high=Double.parseDouble(get_high);
trapezoidArea=(t_up+t_down)*t_high/2;
System.out.println("梯形面積等於:"+trapezoidArea);
}
}
[
本文最後由 Hunag 於 06-10-3 09:15 PM 編輯
]
歡迎光臨 鐵之狂傲 (https://gamez.com.tw/)