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. Please post the code and a screenshot of the output. Thanks!

[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>

Solutions

Expert Solution

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Here a new web page with name "grade.html" is created, which contains following code.

grade.html :

<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

var grade=[];//object grade to hold the Student

//function to get grades and names from the user

function inputGrade()

{ //using for loop to get all names

for(i=0;i<10;i++)

{

var name=prompt("Enter Name","name");//asking and reading name

var grades=parseInt(prompt("Enter Grade","Grade"));//asking and reading grade

//creating Student object and passing name and grade

var student=new Student(grades,name);

grade.push(student);//pushing student in the grade

}

}

//function to show all the grade

function showAlltheGrades()

{

for(i=0;i<10;i++) //using for loop to display details

{

grade[i].detail();//call method on the object

}

}

//function to display MaxGrade

function MaxGrade()

{

//considering first element grade as max grade

var mgrade=grade[0].grade;

var names="";//variable to get name

for(i=0;i<10;i++)

{

if(mgrade<grade[i].grade)//checking grade

{

mgrade=grade[i].grade;//get grade

names=grade[i].name;//get name

}

}

//print max grade and name

document.write("Max Grade:"+mgrade+" Name:"+names);

}

inputGrade();//call function to get input

showAlltheGrades();//call function to display names

MaxGrade();//call function to find max grade

</script>

</body>

</html>

======================================================

Output : Open web page grade.html in the browser and will get the screen as shown below

Screen 1 :grade.html, Screen asking name

Screen 2:Screen asking grade

Screen 3:Screen showing all grades and max grades

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.


Related Solutions

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...
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...
JAVASCRIPT: Please create an array of student names and another array of student grades. - Create...
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...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT