Question

<HTML JAVASCRIPT> Please create an array of student names and another array of student grades. Create...

<HTML JAVASCRIPT>

Please create an array of student names and another array of student grades.

Create a function that can put a name and a grade to the arrays.

Keep Read student name and grade until student name is “???”. And save the reading by using a function

Create another function to show all the grade in that object.

Create the third function that can display the maximum grade and the student’s name.

Create a sorting function that can sort the arrays based on the student’s grade.

Display all the grades and names sorted by the grade.

[Report]

Please copy the JavaScript code output (HTML) in either Notepad++ or NotePad

Homework Answers

Answer #1
<html>
<body>
<script>
//store student name in student array and the grade in grade array
function spush(slist, name, sgrade, grade) {
  slist.push(name);//student list
  sgrade.push(grade);//grade list
}

//show all the student names and their grades
function showlist(slist, sgrade) {
  var i;
  for (i = 0; i < slist.length; i++) {
    document.writeln(slist[i] +" "+sgrade[i]+ "<br>");
  }
}

function findMaxIndex(sgrade){
  var i;
  var max;
  var maxid;
  max = sgrade[0];
  maxid = 0;

  for(i=1;i<sgrade.length; i++){
    if(max < sgrade[i]){
      max = sgrade[i];
      maxid = i;
    }
  }
  
  return maxid;//using index number
}

function swap(arr, i, j){
    var temp = arr[i];
    arr[i] = arr[j];
    arr[j] = temp;
}

function sortData(stdlist, sgrade) {
    var len = stdlist.length
    for (i=0; i < len; i++){
        for (j=0, stop=len-i; j < stop; j++){
            if (sgrade[j] > sgrade[j+1]){
                swap(sgrade, j, j+1);
                swap(stdlist, j, j+1);
            }
        }
    }
}

var stdlist = Array();
var sgrade = Array();
var name
while(name != '???') {
  name = prompt('Enter name of student');
  if(name == '???') {
    break;
  }
  var grade = parseFloat(prompt('Enter grades: '));
  spush(stdlist, name, sgrade, grade);
}

showlist(stdlist, sgrade)
var index = findMaxIndex(sgrade)
document.writeln("The maximum grade: "+stdlist[index]+" "+sgrade[index]);

sortData(stdlist, sgrade)
showlist(stdlist, sgrade)

</script>
</body>
</html>

please upvote.

 
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
The following program allows the user to enter the grades of 10 students in a class...
The following program allows the user to enter the grades of 10 students in a class in an array called grade. In a separate loop, you need to test if a grade is passing or failing, and copy the grade to an array to store passing or failing grades accordingly. A passing grade is a grade greater than or equal to 60. You can assume the use will enter a grade in the range of 0 to 100, inclusive. ...
Assignment #4 – Student Ranking : In this assignment you are going to write a program...
Assignment #4 – Student Ranking : In this assignment you are going to write a program that ask user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’...
Please Use Javascript and HTML 1) Greeter Create an page with an input, and a button....
Please Use Javascript and HTML 1) Greeter Create an page with an input, and a button. When the button is clicked, output the phrase "Hello {Name}" to the developer console, with {Name} being the value the user put into the input field. Use a function that takes the name as an argument, and returns the full phrase as its output.
PART B- Javascript Using a text editor (VS Code or Notepad) and a web browser, you...
PART B- Javascript Using a text editor (VS Code or Notepad) and a web browser, you will demonstrate how to create an HTML file, externally link a JavaScript file, and write some source code in the JavaScript file. a..Create two blank files to be an HTML file and a JavaScript file. The file names should be partA.html and partA.js. b.. Create a basic HTML webpage structure. c..Link the JavaScript file to the HTML file using the <script> tag. d.. Prompt...
[Lab Task HTML/JAVASCRIPT] Please read 10 numbers that are list below, sort the numbers and then...
[Lab Task HTML/JAVASCRIPT] Please read 10 numbers that are list below, sort the numbers and then print those numbers. 10 numbers = { 9, 3, 2, 1, 10, 30, 4, 6, 7, 8} Output should have a sorted list [Reference JavaScript code] <html> <body>     <H1>prompt()</h1>     <p id="pro"></p>     <script>        // Array creation        var num= new Array();               var ix = 0;        // Read 10 numbers        for (ix = 0; ix < 10; ix++)...
Design a solution that requests and receives student names and an exam score for each. Use...
Design a solution that requests and receives student names and an exam score for each. Use one-dimensional arrays to solve this. The program should continue to accept names and scores until the user inputs a student whose name is “alldone”. After the inputs are complete determine which student has the highest score and display that student’s name and score. Finally sort the list of names and corresponding scores in ascending order. When you are done, printout the Code and, also...
PLEASE USE IDLE PYTHON: Question (Arrays/Lists) A teacher uses 2   arrays (or Lists) to keep track...
PLEASE USE IDLE PYTHON: Question (Arrays/Lists) A teacher uses 2   arrays (or Lists) to keep track of his students. One is used to store student names and the other stores his grade (0-100). Write a program to create these two arrays (or lists) that are originally empty, and do the following using a menu: 1. Add a new student and his/her grade. 2. Print the name and grade of all current students, one student per line. 3. Display the number...
write a program that automates the process of generating the final student report for DC faculty...
write a program that automates the process of generating the final student report for DC faculty considering the following restrictions. Consider declaring three arrays for processing the student data: studID studName studGrade The student ID is a random number generated by the 5-digit system in the range of (10000 - 99999). Create a function to assign the student ID generated in an array of numbers. Consider the following to generate the random number: Add the libraries: #include <stdlib.h> #include <ctime>...
C++ //StudentDataStructure.txt //Student records are stored in a parallel-array Data Structure. Here is the code to...
C++ //StudentDataStructure.txt //Student records are stored in a parallel-array Data Structure. Here is the code to generate and populate Parallel-Array Data Structure: const int NG = 4; //Number of Grades string names[] = {"Amy Adams", "Bob Barr", "Carla Carr", "Dan Dobbs", "Elena Evans" }; int exams[][NG]= { {98,87,93,88}, {78,86,82,91}, {66,71,85,94}, {72,63,77,69}, {91,83,76,60} };    --------------------------------------------------------------------------------- 1 A) Create and Populate a Parallel-Array Data Structure using the code described in "StudentDataStructure.txt". B) Define a Record Data Structure for student records. It...
Create a Java Program/Class named MonthNames that will display the Month names using an array. 1....
Create a Java Program/Class named MonthNames that will display the Month names using an array. 1. Create an array of string named MONTHS and assign it the values "January - December". All 12 months need to be in the array with the first element being "January", then "February", etc. 2. Using a loop, prompt me to enter an int variable of 1-12 to display the Month of the Year. Once you have the value, the program needs to adjust the...