0% found this document useful (0 votes)
10 views3 pages

PROGRAM2

The document presents a Java program that demonstrates multiple inheritance using interfaces. It defines two interfaces, Detail and Marks, and a Student class that implements these interfaces to collect and display student information and marks. The program includes user input for student details and calculates the total marks and percentage, displaying the results in a formatted output.

Uploaded by

joyalprincess
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

PROGRAM2

The document presents a Java program that demonstrates multiple inheritance using interfaces. It defines two interfaces, Detail and Marks, and a Student class that implements these interfaces to collect and display student information and marks. The program includes user input for student details and calculates the total marks and percentage, displaying the results in a formatted output.

Uploaded by

joyalprincess
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

PROGRAM-2

To write a java program to implement the concept of Multiple Inheritance using


Interface
SOURCE CODE
import java.util.Scanner;
//Student Detail
interface Detail
{
final String academic_year="2023-2024";
public void getDetail();
}
//Student Marks
interface Marks
{
public void getMarks();
public void maksheet();
}
//multiple inheritance using interface
class Student implements Detail,Marks
{
String rollno,name,degree,sem;
int m1,m2,m3,total;
float percent;
public void getDetail()
{
Scanner in = new Scanner(System.in);
System.out.print("Enter Student Roll Number : ");
rollno = in.nextLine();
System.out.print("Enter Student Name : ");
name = in.nextLine();
System.out.print("Enter degree : ");
degree = in.nextLine();
System.out.print("Enter Sem : ");
sem = in.nextLine();
}

public void getMarks()


{
Scanner in = new Scanner(System.in);
System.out.print("Enter Mark1 : ");
m1 = in.nextInt();
System.out.print("Enter Mark2 : ");
m2 = in.nextInt();
System.out.print("Enter Mark3 : ");
m3 = in.nextInt();
total=m1+m2+m3;
percent=(total*100)/300;
}
public void maksheet()
{
System.out.println("\nAcademic Year: "+academic_year);
System.out.println("Student Roll Number: "+rollno);
System.out.println("Student Name: "+name);
System.out.println("Degree: "+degree);
System.out.println("Semester: "+sem);
System.out.println("Total Marks: "+total);
System.out.println("Percentage: "+percent);
}
}
//main class
class PL2
{
public static void main (String args[])
{
Student s = new Student();
s.getDetail();
s.getMarks();
s.maksheet();
}
}
PROGRAM-2 - OUTPUT
Enter Student Roll Number : 155
Enter Student Name : James
Enter degree : Ai and Ds
Enter Sem : 3rd
Enter Mark1 : 98
Enter Mark2 : 85
Enter Mark3 : 65

Academic Year: 2023-2024


Student Roll Number: 155
Student Name: James
Degree: Ai and Ds
Semester: 3rd
Total Marks: 248
Percentage: 82.0

You might also like