-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathQ_8.java
More file actions
69 lines (62 loc) · 1.63 KB
/
Copy pathQ_8.java
File metadata and controls
69 lines (62 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//Create two packages q8pack1 and q8pack2
//Create q8.java in q8pack1
package q_8pack1;
import java.util.Scanner;
import q_8pack2.Sports;
class Student{
String name;
int roll;
public void input(){
Scanner sc= new Scanner(System.in);
System.out.println("Enter student name: ");
name= sc.nextLine();
System.out.println("Enter roll no: ");
roll=sc.nextInt();
}
public void output(){
System.out.println("Name: "+name+", Roll no: "+roll);
}
}
class Test extends Student{
int mark1, mark2;
public void input(){
super.input();
Scanner sc= new Scanner(System.in);
System.out.println("Enter mark1: ");
mark1=sc.nextInt();
System.out.println("Enter mark2: ");
mark2=sc.nextInt();
}
public void output(){
super.output();
System.out.println("Mark1: "+mark1+", Mark2: "+mark2);
}
}
class GrandTotal extends Test implements Sports{
public void input(){
super.input();
}
public void output(){
super.output();
System.out.println("Score 1: "+score1+" and Score 2: "+score2);
System.out.println("Total mark "+(mark1+mark2)+" and total Score "+(score1+score2));
System.out.println("Grand total : "+(mark1+mark2+score1+score2));
}
}
public class q8 {
public static void main(String[] args) {
GrandTotal g1= new GrandTotal();
g1.input();
g1.output();
}
}
//Create Sports.java in q8pack2
package q_8pack2;
public interface Sports{
int score1=0;
int score2=0;
}
class sport {
public static void main(String[] args) {
}
}