-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab1.java
71 lines (65 loc) · 1.7 KB
/
lab1.java
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
70
71
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Student
*/
import java.util.*;
class Student{
protected int roll;
Scanner sc = new Scanner(System.in);
void getRollNo(){
System.out.println("Enter your roll no.");
roll = sc.nextInt();
}
}
class Test extends Student{
protected float ca1 , ca2 , ca3 , ca4;
Scanner sc = new Scanner(System.in);
void getMarks(){
System.out.println("Enter ca1 ca2 ca3 ca4 marks");
ca1 = sc.nextFloat();
ca2 = sc.nextFloat();
ca3 = sc.nextFloat();
ca4 = sc.nextFloat();
}
void display(){
System.out.println("STUDENT INFO.");
System.out.println("Roll : "+roll+"\nCA1 : "+ca1+"\tCA2 : "+ca2+"\tCA3 : "+ca3+"\tCA4 : "+ca4);
}
}
interface Sports{
float soprtsswt = 6.0f;
void display_s();
}
class Result_pro extends Test implements Sports{
public void display_s(){
System.out.println("Sports weight "+soprtsswt);
}
void makeSystem(){
Test []t = new Test[2];
for(Test t1:t){
t1 = new Test();
t1.getRollNo();
t1.getMarks();
t1.display();
System.out.println(calculate_percentage(t1));
display_s();
}
}
float calculate_percentage(Test t){
return (t.ca1+t.ca2+t.ca3+t.ca4);
}
}
public class Result{
/**
* @param args the command line arguments
*/
public static void main(String ...args) {
Result_pro r = new Result_pro();
r.makeSystem();
}
}