CALCULATE MARKS using JAVA
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, andMark. 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 theInternalMarksinterface. This class includes methods to get and display internal marks for three subjects. -
The
LabMarksclass also implements theExternalMarksinterface, which means it provides methods to get and display external marks for the same three subjects. -
Additionally, the
LabMarksclass implements theMarkinterface, which extends bothInternalMarksandExternalMarksinterfaces. This interface requires the implementation of methods to display the total marks for each subject. -
Inside the
LabMarksclass, there's aScannerobject 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 theLabMarksclass is created, and the methods are called in the following order:getInternalMarks(),getExternalMarks(),showInternalMarks(),showExternalMarks(), andshowTotalMarks().
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.
-1687708779-1962.png)
Project Files
| .. | ||
| This directory is empty. | ||