close
import javax.swing.JOptionPane;
public class PrintVAR {
public static void main(String args[])
{
double a=5,b=3.14,c ; //宣告變數並設定起始值
String d ; //儲存使用者輸入的字串
d = JOptionPane.showInputDialog("輸入半徑");
a = Integer.parseInt(d);
c = b*a*a;//計算圓面積
System.out.println("r = " + a); //輸出半徑
System.out.print("Area = " + c); //用 + 運算子,串聯字串與變數
}
}
文章標籤
全站熱搜