baller923
10-23-2009, 01:49 AM
I am having trouble figuring out where to put the 'while' loop. After the program has gone through, i would like to have a prompt for the user to restart the program, Y would restart and N would terminate it. Thanks for the help!
<script type="text/javascript">
//<![CDATA[
function runJS()
{
var sum = 0;
var average = 0;
var count = parseFloat(prompt("How many numbers do you want to sum up?", "3"));
var i=0;
var total=1;
var number=0;
{
for (var i=1; i<=count; i=i+1)
{
number=prompt("Enter #"+i, "");
total=total*parseFloat(number);
}
average = sum/3;
alert("The average is: " + average + ".\nThe sum is: " + sum + ".");
}
//]]>
more= prompt("Would you like to do another calculation? (Y/N)", "Y");}
</script>
</head>
<body onload="runJS();">
</body>
<script type="text/javascript">
//<![CDATA[
function runJS()
{
var sum = 0;
var average = 0;
var count = parseFloat(prompt("How many numbers do you want to sum up?", "3"));
var i=0;
var total=1;
var number=0;
{
for (var i=1; i<=count; i=i+1)
{
number=prompt("Enter #"+i, "");
total=total*parseFloat(number);
}
average = sum/3;
alert("The average is: " + average + ".\nThe sum is: " + sum + ".");
}
//]]>
more= prompt("Would you like to do another calculation? (Y/N)", "Y");}
</script>
</head>
<body onload="runJS();">
</body>