JSP簡單計算梯形面積實現

2021-09-12 21:32:02 字數 809 閱讀 7370

1.內容:

編寫兩個jsp頁面:main.jsp和lader.jsp,將兩個jsp頁面儲存在同一web服務目錄中。main.jsp使用include動作標記動態載入lader.jsp頁面。lader.jsp頁面可以計算並顯示梯形的面積。當lader.jsp被載入時獲取main.jsp頁面中include動作標記的param子標記提供的梯形的上底、下底和高的值。

2.實現:

(1)main.jsp

(2) lader.jsp

string topline = request.getparameter("topline");

string baseline = request.getparameter("baseline");

string height = request.getparameter("height");

double a = double.parsedouble(topline);

double b = double.parsedouble(baseline);

double h = double.parsedouble(height);

double area = (a+b)*h/2;

%>

梯形的上底為:

梯形的下底為:

梯形的高為:

梯形面積為:

(3)結果

JSP實現簡單的網頁計算器

計算器可以用純 編出來,但是效率比較低,本篇主要是運用jsp內部函式eval 實現計算功能,該函式可以將字元型表示式進行求值。jsp檔案和css樣式表檔案一樣,可以直接寫在html裡面,也可以外部呼叫,我比較喜歡前一種,這樣會比較清晰。html檔案 ff9668 container card cal...

計算圓的面積 QT實現

博主補充部分 該例項是在windows環境下,vs2010搭載qt5實現的。建立專案步驟 1 步驟一 步驟二 步驟三 ifndef calculate h define calculate h include include include includeclass calculate public...

jsp 自動倒數 jsp倒計時簡單實現方法

當前時間毫秒數 long current time1 system.currenttimemillis 結束時間毫秒數 long end time2 1337875200000l 計算時間差 long time2 end time2 current time1 轉換為秒數 int second in...