Question

In: Computer Science

JAVASCRIPT: - Please create an object (grade) with 10 names and 10 grades. - Create a...

JAVASCRIPT:

- Please create an object (grade) with 10 names and 10 grades.
- Create a method (inputGrade) that can put a name and a grade to the grade object.
- Create another method (showAlltheGrades) to show all the grade in that object.
- Create the third method (MaxGrade) that can display the maximum grade and the student name.
- Using “prompt” and inputGrade method input 10 student names and their grades.
- Display all the grades and names by using showAlltheGrades method.

NOTE: Make sure to use the push() method when adding elements to the arrays.

Prefer to use NotePad++ or Note Pad to type code. Please add on to the Pseudo Code and convert it into the javascript needed. Thank you

PLEASE USE THE REFERENCE JAVASCRIPT CODE BELOW!

[Reference JavaScript code]

<<html>

<body>

<script>

// Declare a class

   class Student {

   // initialize an object

      constructor(grade, name) {

           this.grade=grade;

           this.name=name; }

      //Declare a method

      detail() {

        document.writeln(this.grade + " " +this.name)

     }//detail

   }//class

var student1=new Student(1234, "John Brown");

var student2=new Student(2222, "Mary Smith");

student1.detail();//call a method

student2.detail();

</script>

</body>

</html>

[Find max pseudo code]

max← A[1]

while i < 10

if A[i] > max

   max = A[i]

    i ← i + 1

end while

Solutions

Expert Solution

<html>

<body>

<script>

// Declare a class

   class Student {

   // initialize an object

      constructor(grade, name) {

           this.grade=grade;

           this.name=name; }

      //Declare a method

      detail() {

        document.writeln(this.grade + " " +this.name + "</br>")

     }//detail

   }//class

    students = Array();

    function inputGrade() {
      for(var i=0; i<2; i++) {
          var name = prompt('Enter name of student ' + (i + 1))
          var grade = parseInt(prompt('Enter marks of student ' + (i + 1)))
          students.push(new Student(grade, name));

          alert(students[i].grade);
      }
    }

    function showAlltheGrades() {
      for(var i=0; i<students.length; i++) {
          students[i].detail();
      }
    }
    
    function findMaxGrade() {
        var max = students[0];
        for(var i=1; i<students.length; i++) {
            if(students[i].grade > max.grade) {
                max = students[i];
            }
        } 
        document.writeln("</br>Student with max grade:") 
        max.detail();  
    }
    
    inputGrade();
    showAlltheGrades();
    findMaxGrade();

</script>

</body>

</html>
**************************************************

Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.

Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.


Related Solutions

JavaScript - Create a class using "names" as the identifier. Create a constructor. The constructor must...
JavaScript - Create a class using "names" as the identifier. Create a constructor. The constructor must have elements as follow: first ( value passed will be String ) last ( value passed will be String ) age ( value passed will be Numeric ) The constructor will assign the values for the three elements and should use the "this" keyword Create a function, using "printObject" as the identifier printObject: This function will have three input parameters: allNames , sortType, message...
JAVASCRIPT Create an array of 5 objects named "movies" Each object in the movies array, should...
JAVASCRIPT Create an array of 5 objects named "movies" Each object in the movies array, should have the following properties: Movie Name Director Name Year Released WasSuccessful (this should be a boolean and at least 2 should be false) Genre Loop through all of the objects in Array If the movie is successful, display all the movie information on the page. These movies were a success: Title: Forrest Gump Year Realeased: 1994 Director: Robert Zemeckis Genre: Comedy
[Javascript] Create a function(returnObjectFromId(case, ...idNum)) to return the case Object(s) for a given idNum, or list...
[Javascript] Create a function(returnObjectFromId(case, ...idNum)) to return the case Object(s) for a given idNum, or list of idNums. Calling with a single `idNum` value should return the case Object, and return NULL if an id value that's unknown is passed returnObjectFromId(case, 84838) would return the Object in the cases Array with an 'idNumber' of id, and use the .find() method of the cases Array to locate items by idNumber. returnObjectFromId(cases, -23298312) would return null. returnObjectFromId(cases, 161020, 161021) would return an...
Write a program that translates a letter grade into a number grade. Letter grades are A,...
Write a program that translates a letter grade into a number grade. Letter grades are A, B, C, D, and F, possibly followed by + or -. Their numeric values are 4, 3, 2, 1 and 0. There is no F+ or F-. A “+” increases the numeric value by 0.3, a “–“ decreases it by 0.3. However, an A+ has value 4.0.4 pts Enter a Letter grade: B- The numeric value is 2.7 Your code with comments A screenshot...
Please Use JavaScript and P5 1) Greeter Create an page with an input, and a button....
Please Use JavaScript and P5 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.
Please create an Event-Based JavaScript Program of your choice. Please write new code for this project...
Please create an Event-Based JavaScript Program of your choice. Please write new code for this project (starting from scratch). Thank you!!
Write a program in python to read from a file the names and grades of a...
Write a program in python to read from a file the names and grades of a class of students to calculate the class average, the maximum, and the minimum grades. The program should then write the names and grades on a new file identifying the students who passed and the students who failed. The program should consist of the following functions: a) Develop a getGrades() function that reads data from a file and stores it and returns it as a...
Please take the code below and add some javascript to it. Please use javascript inline. Please...
Please take the code below and add some javascript to it. Please use javascript inline. Please be sure to specify within the webpage with something like 'Click here' too show what was done and how to activate it. Please post in a format that can be directly copied. Thank you in advance HINT: add some fun widgets to the page index-css.html: <!DOCTYPE html> <html lang="en"> <head> <!-- title for web page --> <title>Index-CSS Page</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1">...
Create a C++ program that will accept any number of grades for an exam. The grades...
Create a C++ program that will accept any number of grades for an exam. The grades will be input as 4 for an A, 3 for a B, 2 for a C, 1 for a D, and 0 for an F. After all grades have been entered, allow the user to enter -1 to exit. Output the number of grades in each category. Using arrays.
Tensile-strength tests were carried out on two different grades of wire rod. Grade 1 has 10...
Tensile-strength tests were carried out on two different grades of wire rod. Grade 1 has 10 observations yielding a sample mean of 1085 and standard deviation of 52. Grade 2 has 15 observations yielding a sample mean of 1034 and standard deviation of 61. Assume the populations to be approximately normal with equal variances. State and conclude your hypothesis at the 0.05 level of significance if grade 1 and grade 2 true means are equal each other? Find P-Value.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT