import
java.util.*;
import
java.util.Scanner;
interface
Sports_marks
{ final int sm=10;
public void display();
}
class Student
{ int
id;
String name,dept;
void get_data(int id,String name,String dept)
{ this.id=id;
this.name=name;
this.dept=dept;
}
}
Class Marks extends Student
{ int
m1,m2;
void
get_marks(int m1,int m2)
{ this.m1=m1; this.m2=m2;}
}
class Result
extends Marks implements Sports_marks
{ public void display()
{
System.out.print("\nName-
"+name+"\nRoll-no= "+id+"\nDepartment "+dept);
System.out.print("\nMarks
="+(m1+m2+sm));
}
}
class E8
{
public static void main(String args[])
{
int a,b,c; String name = new String(); String
dept = new String();
Result q = new Result();
System.out.println("Enter your
Name,Department,Roll-no and marks for subject 1 and 2");
Scanner s = new Scanner(System.in);
name=s.nextLine();
dept=s.next();
a=s.nextInt();
b=s.nextInt();
c=s.nextInt();
q.get_data(a,name,dept);
q.get_marks(b,c);
q.display();
}
}
OUTPUT
F:\java
program\OOPM>javac E8.java
F:\java
program\OOPM>java E8
Enter your
Name,Department,Roll-no and marks for subject 1 and 2
DONALD
COMPUTERS
24
43
45
Name- DONALD
Roll-no= 24
Department
COMPUTERS
Marks =98
No comments:
Post a Comment