![](/img/trans.png)
[英]How do I change this greedy algorithm to predict the with the most overall score?
[英]Score book using javabean; how do I get overall average?
我有一個體育俱樂部正在編寫的計分簿,我需要獲得最終分數的總體價值。 有5個類別需要考慮,三個類別有3個獨立的部分,需要對其進行評分才能返回最終值,而另外兩個則需要對自己的總體得分進行評分。 我正在編寫一個javabean / jsp程序來完成此任務。 我的表現非常出色,除了現在我需要弄清楚如何獲得總體得分並且我陷入困境。
這是我的成績表.jsp
<html>
<body>
<form action="scoresheet.jsp" method="POST">
<h2>
<u><font color="ff3300">RISC Score Book</font></u>
</h2>
<h3>
Please the player's name:
</h3>
<p></p>
<h4>
First Name: <input type="text" name="first" id="first"><br>
Last Name: <input type="text" name="last" id="last" /><br>
</h4>
<p></p>
<h3>
<u>Please enter the players's bowling scores:</u>
</h3>
<h4>
Game01: <input type="number" name="game01" id="game01"><br>
Game02: <input type="number" name="game02" id="game02"><br>
Game03: <input type="number" name="game03" id="game03"><br>
</h4>
<h3>
<u>Please enter the players's dart scores:</u>
</h3>
<h4>
Dart01: <input type="number" name="dart01" id="dart01"><br>
Dart02: <input type="number" name="dart02" id="dart02"><br>
Dart03: <input type="number" name="dart03" id="dart03"><br>
</h4>
<p></p>
<h3>
<u>Please enter the player's Quoits scores:</u>
</h3>
<h4>
Quoits01: <input type="number" name="quoits01" id="quoits01"><br>
Quoits02: <input type="number" name="quoits02" id="quoits02"><br>
Quoits03: <input type="number" name="quoits03" id="quoits03"><br>
</h4>
<p></p>
<h3>
<u>Please enter the players's Pong & Golf Scores.</u>
</h3>
<h3>
Pong: <input type="number" name="pong" id="pong"><br>
</h3>
<p></p>
<h3>
Golf: <input type="number" name="golf" id="golf"><br>
</h3>
<input type="submit" value="Submit" id='scoreSubmit' />
</form>
</body>
</html>
這是我編寫的一些bean代碼的示例:
public String getGame01() {
return Game01;
}
public void setGame01(String Game01) {
this.Game01 = Game01;
}
public String getGame02() {
return Game02;
}
public void setGame02(String Game02) {
this.Game02 = Game02;
}
public String getGame03() {
return Game03;
}
public void setGame03(String Game03) {
this.Game03 = Game03;
}
因此,與上述代碼類似,所有具有三個部分的所有三個類別都寫在Bean中。 我為上面的bean寫的便捷方法是獲得三個游戲的平均值,這個例子是:
public double getGameAverage() {
String[] games = new String[]{game01, game02, game03};
int sum = 0;
for (String input : games) {
sum += Double.parseDouble(input);
}
return (sum * (10) / 3);
}
這樣我就可以得出前三場比賽的成績(保齡球,飛鏢和魁北克)。 對於高爾夫和乒乓球,我們只是獲得一個單一的游戲分數並將其納入最終分數。
好的,這就是設置。...這是我的問題:
我需要從保齡球,飛鏢和高爾夫球中獲取數字,再從高爾夫球和乒乓中獲取數字,然后將等式應用於它們:
保齡球總價值的25%
價值飛鏢:總體平均水平的20%
價值指標:整體平均值的20%
乒乓球:整體平均值的10%
超值保齡球:總體平均值的25%。
我不知道如何從用戶輸入的兩個值(高爾夫球和乒乓球)以及Bean計算的三個值中獲得收益,並將此等式應用於他們:
{
((Bowl)*(.25))
+
((Darts)*(.20))
+
((Quoits)*(.20))
+
((Pong)*(.20))
+
((Golf)*(.20))
}
= 100%
任何幫助將不勝感激。 我對此有些困惑,對Java,.jsp和servlet來說還很新。
為什么不使用任何數字來獲得總分。 例如,如果Bowl =(25/100)* overAllScore,則意味着overAllScore = 100 * Bowl / 25
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.