<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> 10 person Age sum </title>
<body>
Enter the age of 10 people from prompt into the array, and sum the ages of 10 people.
</body>
<script>
var array=new array ()
Array[0]=prompt ("Please enter the age of the first person");
Array[1]=prompt ("Please enter a second person's age");
Array[2]=prompt ("Please enter the age of a third person");
Array[3]=prompt ("Please enter a fourth person's age");
Array[4]=prompt ("Please enter a fifth person's age");
Array[5]=prompt ("Please enter a sixth person's age");
Array[6]=prompt ("Please enter a seventh person's age");
Array[7]=prompt ("Please enter a eighth person's age");
Array[8]=prompt ("Please enter a nineth person's age");
Array[9]=prompt ("Please enter a tenth person's age");
A=ARRAY[0];
B=ARRAY[1];
C=ARRAY[2];
D=ARRAY[3];
E=ARRAY[4];
F=ARRAY[5];
G=ARRAY[6];
H=ARRAY[7];
I=ARRAY[8];
J=ARRAY[9];
if (a!= "&&b!=" "&&c!=" "&&d!=" "&&e!=" "&&f!=" "&&g!=" "&&h! = "" &&i!= "" &&j!= "")
{
var aa=parsefloat (a);
var bb=parsefloat (b);
var cc=parsefloat (c);
var dd=parsefloat (d);
var ee=parsefloat (e);
var ff=parsefloat (f);
var gg=parsefloat (g);
var hh=parsefloat (h);
var ii=parsefloat (i);
var jj=parsefloat (j);
if (aa%1==0&&bb%1==0&&cc%1==0&&dd%1==0&&ee%1==0&&ff%1==0&&gg%1= =0&&hh%1==0&&i%1==0&&j%1==0&&
aa>=0&&aa<=135&&bb>=0&&bb<=135&&cc>=0&&cc<=135& &dd>=0&&dd<=135&&
ee>=0&&ee<=135&&ff>=0&&ff<=135&&gg>=0&&gg<=135& &hh>=0&&hh<=135&&ii>=0&&ii<=135&&jj>=0&&jj<=135)
{
Array[0]=parseint (a);
Array[1]=parseint (b);
Array[2]=parseint (c);
Array[3]=parseint (d);
Array[4]=parseint (e);
Array[5]=parseint (f);
Array[6]=parseint (g);
Array[7]=parseint (h);
Array[8]=parseint (i);
Array[9]=parseint (j);
var sum=0;
for (z=0;z<10;z++)
{Array[z]=parseint (array[z])
SUM=SUM+ARRAY[Z]
}
document.write ("The sum of the ages is:" +sum)
}
Else
{
Alert ("Not in range")
}
}
Else
{
Alert ("Input error cannot be null")
}
</script>
Enter the age of 10 people from prompt into the array, and sum the ages of 10 people.