Question
Your task is to create an application named teacher.html that allows a teacher to enter the name and the test scores for a student at
Your task is to create an application named teacher.html that allows a teacher to enter the name and the test scores for a student at a point of a semester the scores are as low as 0 and as high as 100. After each entry, the application should continue to prompt the user if they would like to enter another score the user must type Y or N. When the user indicates that they have no more scores to enter for that particular student, the user should be prompted if they would like to enter another student (Y or N) and continue on. Once the user is done entering students and their scores, each student with their average score should be displayed in one alert box. Entering Student Names Should not be empty If it is empty, the user should continually be asked to enter until correct All of this logic should exist inside one function Entering Student Scores Should not be empty Should be between 1 100 inclusive If invalid, the user should continually be asked to enter until correct All of this logic should exist inside a second function Entering Whether There is Another Score OR Whether There is Another Student Should not be empty Can only be Y or y or N or n If invalid, the user should continually be asked to enter until correct. NOTE: The message should be specific as to whether or not the user should be entering another student or another score. Watch the demo video for further clarification. All of this logic should exist inside a third function Calculating Average All of the logic that determines the average score should exist inside a fourth function. Storing Each students Name and Average Score Each student name must be stored inside an array Each average score for each student must be stored inside a different array For example, after all of the students and their scores are entered, two arrays like the following should have been built dynamically (as in, you dont manually type this inthese arrays are built while the program runs): var students = [Paul, Sarah, Chet]; var scores = [99, 2, 88]; In this example, Pauls average score is 99, Sarahs is 2, and Chets is 88. (Paul is element 0 in both arrays, Sarah is element 1, and Chet is element 2). Displaying the Final Output The output should look like (names and scores may differ): Test Data WATCH THIS DEMO VIDEO The Test data that will be used to ensure the program works is as follows Name Score Score Score Score Paul 100 98 95 100 Sarah 4 8 Chet 88 34 100 o Pauls average should be 98% o Sarahs average should be 6% o Chets average should be 74% I will also be testing that names and scores cannot be left blank I will also be testing that scores are between 1 and 100 inclusive I will also be testing that only Y or y or N or n are valid answers to whether or not I would like to add another score or another student and that the invalid message is specific to whether I was entering a score or a student (Javascript)
The problem is that i need it while looped. please help.
my code:
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 more than 100"); }
else{
score = score + parseInt(promtScore); console.log(score);
numberOfSubject++;
console.log(numberOfSubject);
optionCheckScore();
}
}
function optionCheckScore(){
var nextScore = prompt("Enter another score? Y or N");
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 or N");
}
}
function optionCheckStudent(){
var nextStudent = prompt("Enter Another Student? Y or N");
if(nextStudent=="Y"||nextStudent=="y"){
enterStudentName();
}
else if(nextStudent=="N"||nextStudent=="n"){
displayOutput();
}
else{
alert("Invalid Option. Enter another student? Y or N");
}
}
function displayOutput(){
var output = "";
for(var i = 0;i < stName.length; i++){
output = " " + output + stName[i] + " - " + averageScore[i] + "% ";
}
output = "**STUDENT/SCORES** " + output;
alert(output);;
var outputHTML = "";
for(var i = 0;i < stName.length; i++){
outputHTML = outputHTML + " " + stName[i] + " - " + averageScore[i] + "% ";
}
document.getElementById("output").innerHTML = "**STUDENT/SCORES** " + outputHTML;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started