Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

HTML/JAVASCRIPT - Find the average of 25 students for a test. Its okay to use a

ID: 3593554 • Letter: H

Question

HTML/JAVASCRIPT - Find the average of 25 students for a test. Its okay to use a loop to enter the student names and their grades and then a separate output area that calculates the average. Basically, a pop up box asking for the name and score of the student, (student 1 - Name: James | Score: 95, student 2 - Name: Nancy | Score: 75.6, student 3 - Name: Joe | Score: 82... etc) and then an ouput showing each individual's name and their individual score and finally the average of the 25 students' scores.

Thanks!

Explanation / Answer

Below is the program in HTML/Javascript which takes Name and Mraks of 25 students in a pop up box and then displaying the name, marks, sum of marks of 25 students, average marks of 25 students in a page.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!-- Welcome -->

<!-- Getting the name and marks of 25 students and displaying their names, marks, average marks of

25 students -->

<html>

<head>

<title>Compare Numbers</title>

<script type="text/javascript">

var studentName = new Array(25);

studentMarks = new Array(25),

sum = 0,

avg = 0;

for (i = 1; i <= 25; i++) // Collecting name and marks of 25 students

{

studentName[i] = window.prompt("Enter student " + i + Name:");

studentMarks[i] = parseInt(window.prompt("Enter student " + i + Marks:"));

sum = sum + studentMarks[i]; // Calculating sum of marks

}

avg = sum / 25; // Calculating average marks of 25 students

var table1 = document.getElementById("studentTable"); // Adding table rows for showing name and marks of student

var row = table1.insertRow(0);

var student = row.insertCell(0);

var marks = row.insertCell(1);

student.innerHTML = "Student Name";

marks.innerHTML = "Marks";

var nameRow = new Array(25);

var marksRow = new Array(25);

var row1 = new Array(25);

for (i = 1; i <= 25; i++)

{

row1[i] = table1.insertRow(i);  

nameRow[i] = row1[i].insertCell(0);

marksRow[i] = row1[i].insertCell(1);

nameRow[i].innerHTML = studentName[i];

marksRow[i].innerHTML = studentMarks[i];

}

var sumRow = table1.insertRow(26); // Adding table row for displaying sum of marks of 25 students

var sum = sumRow.insertCell(0);

var total = sumRow.insertCell(1);

sum.innerHTML = "Sum";

total.innerHTML = sum;

var avgRow = table1.insertRow(27); // Adding table row for displaying sum of marks of 25 students

var avg = avgRow.insertCell(0);

var total1 = avgRow.insertCell(1);

avg.innerHTML = "Average";

total1.innerHTML = avg;

  

</script>

</head>

<body>

<h1>Student Marks Average!</h1>

<form name = "form1" >

<table id = "studentTable">

  

</table>

</form>

</body>

</html>