html - take 5 numbers one at a time from a form in a jsp page and calculate the average with a java class? -


I have a form, I want these input numbers at the same time.

I pass an object and getParameter () values,

   & Lt; Input type = "hidden" name = "hidden control" value = "" /> & Lt;% string input = request.getParameter ("input"); String hidden quarters = request.GetPamator ("hidden quarter"); Control. Main program main = new control Main program (input, hidden control); & Gt%; & Lt; Input type = "submit" value = "submit number" /> & Lt;% out.println (main .getResult ()); & Gt%; & Lt; / Form & gt;   

In the Java class, the constructor valves the value and sets the variable

  public keyprogram (string input, string hidden control) {try {number = Integer.parseInt (input); Counter = integer Parseint (hidden control); } Hold (NumberFormatException e) {}} Public int getResult () {Return Number; }   

How can I add numbers to each number presented?

The problem every time the constructor is called, it sets the number to the number submitted to the variable.

Something like this

  number + = number;   

Explicit work (variables due to its reset)

ive Search & amp; Can anyone help?

If you are not concerned about multi-threaded access, you can only select numbers < / Code> static

variable will be bound to control.MainProgram class instead of an example.

Then you ... try

  {number + = integer.PERSIN (input); Also declare as   

... then getResult still ...

... Then open it by & lt;% out.println (control.MainProgram.getResult ()); % & Gt;

Note that this does not give you an average, because your title means - it gives you the amount.

But it is simple to apply the average in your body of stable int getResult method.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -