[問題] 我的程式哪裡有問題?
import java.util.*;
public class TrapArea {
public static void main(String[] argv) {
Scanner scan = new Scanner(System.in);
boolean Again = true;
char YN;
double Upper, Lower, Height, Area;
System.out.println("Calculate a trapezoid\'s area");
while (Again == true){
Upper = Lower = Height = Area = 0;
System.out.print("Input the trapezoid\'s upper base(cm):");
Upper = scan.nextDouble(); //The upper base of the trapezoid
System.out.print("\r\nInput the trapezoid\'s lower base(cm):");
Lower = scan.nextDouble(); //The lower base of the trapezoid
System.out.print("\r\nInput the trapezoid\'s height(cm):");
Height = scan.nextDouble(); //The height of the trapezoid
Area = (Upper + Lower) /2 *Height; //The area of the trapezoid
System.out.println("\r\nThe area of the trapezoid is" + Area + "cm2");
System.out.print("Do you want to calculate another trapezoid\'s area?
Input Y or N.");
YN = scan.nextChar();
if (YN == 'N'){
Again = false;
}
}
}
}
-----------------------------------------------------------------------------
如上
我在編譯它時,會跳出
https://imgur.com/NdRqQZG
請問要如何修改呢???
(第一次發文)
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.243.2.30
※ 文章網址: https://www.ptt.cc/bbs/java/M.1508312764.A.9CE.html
→
10/18 15:53,
6年前
, 1F
10/18 15:53, 1F
→
10/18 15:54,
6年前
, 2F
10/18 15:54, 2F
→
10/18 15:56,
6年前
, 3F
10/18 15:56, 3F
→
10/18 15:58,
6年前
, 4F
10/18 15:58, 4F
→
10/18 15:59,
6年前
, 5F
10/18 15:59, 5F
→
10/18 16:01,
6年前
, 6F
10/18 16:01, 6F
→
10/18 16:18,
6年前
, 7F
10/18 16:18, 7F
→
10/18 16:36,
6年前
, 8F
10/18 16:36, 8F
→
10/18 21:15,
6年前
, 9F
10/18 21:15, 9F
→
10/20 06:47,
6年前
, 10F
10/20 06:47, 10F
→
10/23 21:24,
6年前
, 11F
10/23 21:24, 11F