How do i calculate the average value of various radio buttons in a servlet using java?
badGuy
2009-10-11 04:07:07 UTC
I have like five questions with five radio buttons each, each radio button has a number value like 2,3 and so on. After clicking the submit button i want to calculate the average of these values and display it. Please i need the code..thanks
Three answers:
deonejuan
2009-10-11 07:35:36 UTC
I don't know your level of expertise.
A radiobutton is an XOR by design -- 1 choice out of many.
A checkbox is -- 1 stab or multiple stab from the choices.
Without knowing what you know, maybe you should use a long String of dot. The dots paralell the same number of checkboxes you have. The .setName of your button widgets are cleverly designed as rb0... rb1...rb2, rb3. Use the numeric after indexOf("b"). That numeric as a decimal value changes a dot into your 2, or 3, or 4, whatever you think the checkbox answer is worth, but you replace dot with decimal-comma.
At the end of PgmQuest
String[] qPts = dots.split(",");
anonymous
2016-04-07 09:00:37 UTC
Remember to test each function. Read the error message and check the line numbers that are listed.
anonymous
2009-10-11 04:40:36 UTC
Then you had better get your Java manual and class notes out and get THINKING ! How do you expect to learn when other people do your homework for you.
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.