简体   繁体   English

使用Javabean评分书; 我如何获得整体平均水平?

[英]Score book using javabean; how do I get overall average?

I have a scorebook that I am writing for a sports club that I need to get an overall value for a final score. 我有一个体育俱乐部正在编写的计分簿,我需要获得最终分数的总体价值。 There are 5 categories that need to be taken into consideration, three categories have 3 separate parts that need to be scored to return a final value, the other two are scored on their own for an over all score. 有5个类别需要考虑,三个类别有3个独立的部分,需要对其进行评分才能返回最终值,而另外两个则需要对自己的总体得分进行评分。 I am writing a javabean/jsp program to accomplish this task. 我正在编写一个javabean / jsp程序来完成此任务。 I works very well except now I need to figure out how to get an overall score and I'm stuck. 我的表现非常出色,除了现在我需要弄清楚如何获得总体得分并且我陷入困境。

Here is my score sheet .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>

Here is an example of some of the bean code that I wrote: 这是我编写的一些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;
                                     }

So all three of the categories that have three parts are written in the bean similar to the above code. 因此,与上述代码类似,所有具有三个部分的所有三个类别都写在Bean中。 The convenience method that I wrote for the above bean to get the average of the three games is this example: 我为上面的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);
                                        }

So I can get the averages of the first three games(Bowling, Darts and Quoits) in this manner. 这样我就可以得出前三场比赛的成绩(保龄球,飞镖和魁北克)。 For golf and pong we are just taking a single game score and incorporating it in to the final score. 对于高尔夫和乒乓球,我们只是获得一个单一的游戏分数并将其纳入最终分数。

Ok, that's the setup....here is my issue: 好的,这就是设置。...这是我的问题:

I need to take the numbers from Bowling, Darts and Golf plus the numbers I get from golf and pong and apply this equation to them: 我需要从保龄球,飞镖和高尔夫球中获取数字,再从高尔夫球和乒乓中获取数字,然后将等式应用于它们:

Value Bowling: 25% of overall average 保龄球总价值的25%

Value Darts: 20% of overall average 价值飞镖:总体平均水平的20%

Value Quoits: 20% of overall average 价值指标:整体平均值的20%

Value Pong: 10% of overall average 乒乓球:整体平均值的10%

Value Bowling: 25% of overall average. 超值保龄球:总体平均值的25%。

I don't know how to get the return from the two values input by the user (Golf and Pong) and the three values calculated by the bean and apply this equation to them: 我不知道如何从用户输入的两个值(高尔夫球和乒乓球)以及Bean计算的三个值中获得收益,并将此等式应用于他们:

{
((Bowl)*(.25))
+
((Darts)*(.20))
+
((Quoits)*(.20))
+
((Pong)*(.20))
+
((Golf)*(.20))
} 
= 100%

Any help would be greatly appreciated. 任何帮助将不胜感激。 I'm a tad confused on this one and pretty new to java, .jsp and servlets. 我对此有些困惑,对Java,.jsp和servlet来说还很新。

Why not use any of the numbers to get the overall score. 为什么不使用任何数字来获得总分。 For instance if Bowl=(25/100)*overAllScore, it means overAllScore=100*Bowl/25 例如,如果Bowl =(25/100)* overAllScore,则意味着overAllScore = 100 * Bowl / 25

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM