Menu

Task Create Application Named Teacherhtml Allows Teacher Enter Name Test Scores Student Po Q43820376

Your task is to create an application named teacher.html thatallows a teacher to enter the name and the test scores for astudent at a point of a semester – the scores are as low as 0 andas high as 100. After each entry, the application should continueto prompt the user if they would like to enter another score – theuser must type Y or N. When the user indicates that they have nomore scores to enter for that particular student, the user shouldbe prompted if they would like to enter another student (Y or N)and continue on. Once the user is done entering students and theirscores, each student with their average score should be displayedin one alert box. Entering Student Names • Should not be empty • Ifit is empty, the user should continually be asked to enter untilcorrect • All of this logic should exist inside one functionEntering Student Scores • Should not be empty • Should be between 1– 100 inclusive • If invalid, the user should continually be askedto enter until correct • All of this logic should exist inside asecond function Entering Whether There is Another Score OR WhetherThere is Another Student • Should not be empty • Can only be Y or yor N or n • If invalid, the user should continually be asked toenter until correct. NOTE: The message should be specific as towhether or not the user should be entering another student oranother score. Watch the demo video for further clarification. •All of this logic should exist inside a third function CalculatingAverage • All of the logic that determines the average score shouldexist inside a fourth function. Storing Each student’s Name andAverage Score • Each student name must be stored inside an array •Each average score for each student must be stored inside adifferent array • For example, after all of the students and theirscores are entered, two arrays like the following should have beenbuilt dynamically (as in, you don’t manually type this in…thesearrays are built while the program runs): var students = [“Paul”,“Sarah”, “Chet”]; var scores = [99, 2, 88]; • In this example,Paul’s average score is 99, Sarah’s is 2, and Chet’s is 88. (Paulis element 0 in both arrays, Sarah is element 1, and Chet iselement 2). Displaying the Final Output • The output should looklike (names and scores may differ): Test Data – WATCH THIS DEMOVIDEO • The Test data that will be used to ensure the program worksis as follows Name Score Score Score Score Paul 100 98 95 100 Sarah4 8 Chet 88 34 100 o Paul’s average should be 98% o Sarah’s averageshould be 6% o Chet’s average should be 74% • I will also betesting that names and scores cannot be left blank • I will also betesting that scores are between 1 and 100 inclusive • I will alsobe testing that only Y or y or N or n are valid answers to whetheror not I would like to add another score or another student andthat the invalid message is specific to whether I was entering ascore or a student (Javascript)

The problem is that i need it while looped. please help.

my code:

<script>

   var averageScore = new Array();
   var stName = new Array();
   var score = 0;
   var numberOfSubject = 0;

   enterStudentName();

   function enterStudentName(x){
   {
   var addName = prompt(“Enter Student Name”);
   }

   if(addName == null || addName == “”)
   {
      
   alert(“Cannot leave field blank. Enter again”);

   return(x);
   }

   else{

   stName.push(addName);

   enterScore();
   }

}

   function enterScore(){

   var promtScore = prompt(“Enter Student Score”);

   if(promtScore == null || promtScore == “” ||promtScore < 0 || promtScore > 100){

   alert(“Score cannot be null or less than 0 or morethan 100”);
   }

   else{

   score = score + parseInt(promtScore);
  
   console.log(score);

   numberOfSubject++;

   console.log(numberOfSubject);

   optionCheckScore();

}

}

   function optionCheckScore(){

   var nextScore = prompt(“Enter another score? Y orN”);

   if(nextScore==”Y”||nextScore==”y”){

   enterScore();

   }

   else if(nextScore==”N”||nextScore==”n”){

   var average = score / numberOfSubject ;

   score = 0;

   numberOfSubject = 0;

   averageScore.push(average);

   optionCheckStudent();

   }

   else{

   alert(“Invalid Option. Enter another score? Y orN”);

}

}

   function optionCheckStudent(){

   var nextStudent = prompt(“Enter Another Student? Yor N”);

   if(nextStudent==”Y”||nextStudent==”y”){

   enterStudentName();

   }

   else if(nextStudent==”N”||nextStudent==”n”){

   displayOutput();

   }

   else{

   alert(“Invalid Option. Enter another student? Y orN”);

}

}

   function displayOutput(){

   var output = “”;

   for(var i = 0;i < stName.length; i++){

   output = “n” + output + stName[i] + ” – ” +averageScore[i] + “% n”;

}

output = “**STUDENT/SCORES** n” + output;

alert(output);;

var outputHTML = “”;

for(var i = 0;i < stName.length; i++){

outputHTML = outputHTML + “<br>” + stName[i] + ” – ” +averageScore[i] + “% <br>”;

}

document.getElementById(“output”).innerHTML =”**STUDENT/SCORES** <br>” + outputHTML;

}

</script>

Expert Answer


Answer to Your task is to create an application named teacher.html that allows a teacher to enter the name and the test scores for…

OR