Answer to Question #265660 in Java | JSP | JSF for gayatri

Question #265660

We want to calculate the total marks of each student of a class in Physics, Chemistry


and Mathematics and the average marks of the class. The number of students in the


class is entered by the user. Create a class named Marks with data members for roll


number, name and marks. Create three other classes inheriting the Marks class,


namely Physics, Chemistry and Mathematics, which are used to define marks in


individual subject of each student. Roll number of each student will be generated


automatically.


1
Expert's answer
2021-11-13T23:51:18-0500
public class Marks {
    private int rollNumber;
    private String name;
    private double marks;

    public Marks(String name, double marks) {
        this.name = name;
        this.marks = marks;
    }
}


public class Physics extends Marks{
    public Physics(String name,double marks){
        super(name, marks);
    }
}


public class Mathematics extends Marks {
    public Mathematics(String name, double marks) {
        super(name, marks);
    }
}


public class Chemistry extends Marks{

    public Chemistry(String name,double marks){
        super(name, marks);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS