answersLogoWhite

0


Best Answer

You could do this using Javascript.
1) create a textfield
2) create a submit button
3) define two Javascript variables: a running tally, and a click-counter
4) give the button an onclick event that calls a function that works like this:

read the value from the text field
convert it to a numeric value
if that value is 0 {
if the counter != 0 {

display the tally and the average (which equals tally over counter)

}else{
either display an error message, or 0 as both the tally and average - to your taste.

}
reset both the tally and the counter to 0

}else{
add the value to the tally
increment the counter by 1

}

And here's a working example of how to do it:




The Summinator!



Add Value







You can even make it a little nicer by having it output the sum and average each time a number is entered, rather than waiting for the zero input (which would still reset things). That actually simplifies the code too, and would look like this:

...

if(isNaN(num)){ // make sure they entered a number
alert("Please enter a numeric value.");

}else{
if(num != 0){
tally += num;
counter ++;
sum = tally;
avg = tally / counter;

}else{
sum = avg = tally = counter = 0;

}

sumfield.innerHTML = "The sum is " + sum;
avgfield.innerHTML = "The average is " + avg;

}

...

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do I create a web page that lets a user enter as many values as they wish until the entry of a 0. Then find the sum and the average of all the numbers and show sum and average on screen. In code?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How is the average for the set of values calculated?

The average is the ratio between the sum of these values and the number of values.


How do you find the math average?

To find the average of a set of numbers, you add all the numbers together. Then you divide this sum by the size of the set - for instance, if you have 10 numbers, you divide the sum by 10.


Sums numbers then divides by the number of values?

average function


What are the sums numbers then divides by the number of values?

The average or arithmetic mean.


Sums numbers in range and divides by number of values?

Average Function


How do you type in numbers in a chart in Excel?

That depends on what you mean. You can type numbers into the titles. You can type numbers into a text box that you create yourself. You can show the values for what is on the chart by adding Data Labels in the Chart Options.That depends on what you mean. You can type numbers into the titles. You can type numbers into a text box that you create yourself. You can show the values for what is on the chart by adding Data Labels in the Chart Options.That depends on what you mean. You can type numbers into the titles. You can type numbers into a text box that you create yourself. You can show the values for what is on the chart by adding Data Labels in the Chart Options.That depends on what you mean. You can type numbers into the titles. You can type numbers into a text box that you create yourself. You can show the values for what is on the chart by adding Data Labels in the Chart Options.That depends on what you mean. You can type numbers into the titles. You can type numbers into a text box that you create yourself. You can show the values for what is on the chart by adding Data Labels in the Chart Options.That depends on what you mean. You can type numbers into the titles. You can type numbers into a text box that you create yourself. You can show the values for what is on the chart by adding Data Labels in the Chart Options.That depends on what you mean. You can type numbers into the titles. You can type numbers into a text box that you create yourself. You can show the values for what is on the chart by adding Data Labels in the Chart Options.That depends on what you mean. You can type numbers into the titles. You can type numbers into a text box that you create yourself. You can show the values for what is on the chart by adding Data Labels in the Chart Options.That depends on what you mean. You can type numbers into the titles. You can type numbers into a text box that you create yourself. You can show the values for what is on the chart by adding Data Labels in the Chart Options.That depends on what you mean. You can type numbers into the titles. You can type numbers into a text box that you create yourself. You can show the values for what is on the chart by adding Data Labels in the Chart Options.That depends on what you mean. You can type numbers into the titles. You can type numbers into a text box that you create yourself. You can show the values for what is on the chart by adding Data Labels in the Chart Options.


How to you work out the values when you have average and number of values?

There is not enough information. For example, 2 numbers, whose average is 10 could be -50 and 70 or 10 and 10 or 9 and 11 or 7.5 and 12.5 etc. All that you know in this case is that the sum of the two numbers = average*number of values = 10*2 = 20


How is the average for a set of values calculated?

The sum of all numbers in the set divided by the count of all numbers in the set


What does mean value in science mean?

the mean is the average of the numbers. It is one of several different ways of determining the average of a set of values. It is determined by adding the sum of all of the values, then dividing by the number of values.


What sums of numbers then divides by the number of values?

That sounds like the mean average.


What function would you use to find the mean in a Microsoft Excel document?

The AVERAGE function returns the average (arithmetic mean) of the numbers provided.=AVERAGE(number1,number2,...number_n)number1, number2, ... number_n are numeric values. They can be numbers, named ranges, arrays, or references to numbers. You can enter up to 30 values.


How do you add up then divide the number of values?

This process enables you to find the "mean" or "average" of a set of values. Example. 12, 7, 5, 1, -3, -4 We have a set of 6 values (numbers) When these 6 numbers are summed : 12 + 7 + 5 + 1 +(-3) + (-4) = 18 Then 18 ÷ 6 = 3..........and 3 is the mean (average) of this set of numbers.