Question: Hello, Can you please error check my javascript? It should do the following: Write a program that uses a class for storing student data. Build

Hello,

Can you please error check my javascript? It should do the following:

Write a program that uses a class for storing student data. Build the class using the given information.

The data should include the students ID number; grades on exams 1, 2, and 3; and average grade.

Use appropriate assessor and mutator methods for the grades (new grades should be passed as parameters).

Use a mutator method for changing the student ID.

Use another method to calculate the average grade.

Write a static method that will accept the two students as parameters and report which one has the highest average grade.

Test all constructors and methods using a separate driver class.

Here is my code so far:

public class Student

{

private int stuID;

private int grade1;

private int grade2;

private int grade3;

private int gradeAvg;

Student()

{

stuID=1;

grade1=90;

grade2=100;

grade3=98;

}

Student(int sID,int sgrade1,int sgrade2,int sgrade3)

{

stuID=sID;

grade1=sgrade1;

grade2=sgrade2;

grade3=sgrade3;

}

public int getStuID()

{

return stuID;

}

public void setStuID(int stuID)

{

this.stuID = stuID;

}

public int getGrade1()

{

return grade1;

}

public void setGrade1(int grade1)

{

this.grade1 = grade1;

}

public int getGrade2()

{

return grade2;

}

public void setGrade2(int grade2)

{

this.grade2 = grade2;

}

public int getGrade3()

{

return grade3;

}

public void setGrade3(int grade3)

{

this.grade3 = grade3;

}

int calculateAvgGrade()

{

gradeAvg=((grade1+grade2+grade3)/3);

return gradeAvg;

}

public static int HighGrade(Student s1, Student s2)

{

return(Math.max(s1.gradeAvg,s2.gradeAvg));

}

public static int HighGradeStudent(Student s1, Student s2)

{

if(s1.gradeAvg>s2.gradeAvg)

{

return(s1.stuID);

}

else

{

return(s2.stuID);

}

}

}

class StudentDemo

{

public static void main(String args[])

{

Student s1 = new Student();

System.out.println("Data of Student 1");

System.out.println("Student ID is: "+s1.getStuID());

System.out.println("Student grade1 is: "+s1.getGrade1());

System.out.println("Student grade2 is: "+s1.getGrade2());

System.out.println("Student grade3 is: "+s1.getGrade3());

System.out.println("Student1 Average grade is: "+s1.calculateAvgGrade());

Student s2 = new Student(2,80,90,100);

System.out.println(" Data of Student 2");

System.out.println("Student ID is: "+s2.getStuID());

System.out.println("Student grade1 is: "+s2.getGrade1());

System.out.println("Student grade2 is: "+s2.getGrade2());

System.out.println("Student grade3 is: "+s2.getGrade3());

System.out.println("Student2 Average grade is: "+s2.calculateAvgGrade());

Student s3 = new Student();

System.out.println(" Highest average grade is: "+s3.HighGrade(s1,s2));

System.out.println("Student ID who has got Highest grade:"+s3.HighGradeStudent(s1,s2));

}

}

Error: Main method not found in class Student, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application Command exited with non-zero status 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!