This program takes the marks of a student as an input and shows the result as an output.
The given Java code represents a program that calculates and displays the internal marks, external marks, and total marks for three subjects. The program uses interfaces and classes to organize the code.
Here's a breakdown of the code:
The program defines three interfaces: InternalMarks
, ExternalMarks
, and Mark
. Each interface declares a set of methods related to internal marks, external marks, and total marks.
The program then defines a class called LabMarks
, which implements the InternalMarks
interface. This class includes methods to get and display internal marks for three subjects.
The LabMarks
class also implements the ExternalMarks
interface, which means it provides methods to get and display external marks for the same three subjects.
Additionally, the LabMarks
class implements the Mark
interface, which extends both InternalMarks
and ExternalMarks
interfaces. This interface requires the implementation of methods to display the total marks for each subject.
Inside the LabMarks
class, there's a Scanner
object to read input from the user.
The getInternalMarks()
method prompts the user to enter the internal marks for the three subjects and stores them in variables.
The getExternalMarks()
method prompts the user to enter the external marks for the three subjects and stores them in variables.
The showInternalMarks()
method displays the internal marks for the three subjects.
The showExternalMarks()
method displays the external marks for the three subjects.
The showTotalMarks()
method calculates and displays the total marks for each subject, which is the sum of internal and external marks.
In the main()
method, an instance of the LabMarks
class is created, and the methods are called in the following order: getInternalMarks()
, getExternalMarks()
, showInternalMarks()
, showExternalMarks()
, and showTotalMarks()
.
To run this code, you can save it in a Java file (e.g., "LabMarks.java") and compile and execute it using a Java compiler and runtime environment.
Submitted by Kunal Kanti Saha (kunal0010)
Download packets of source code on Coders Packet
Comments