forked from chetannihith/Java-hacktoberfest23
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjava code for #22
53 lines (45 loc) · 1.38 KB
/
java code for #22
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
package com.company;
public class School_pQ1 {
String name,Address,Branch,grade,bmlId;
int sub1,sub2,sub3,sub4,roll;
float per;
void getData(String n, int r,String a,String b,int s1,int s2,int s3,int s4) {
name = n;
Address=a;
Branch=b;
roll = r;
sub1=s1;
sub2=s2;
sub3=s3;
sub4=s4;
per = (float) ((sub1+sub2+sub3+sub4)/4.0);
if (per >= 80) {
grade = "A";
} else if (per >= 60) {
grade = "B";
} else if (per >= 45) {
grade = "C";
} else if (per >= 40) {
grade = "D";
} else {
grade = "F";
}
}
void putData(){
System.out.println("Marks in sub1:"+sub1);
System.out.println("Marks in sub2:"+sub2);
System.out.println("Marks in sub3:"+sub3);
System.out.println("Marks in sub4:"+sub4);
System.out.println("name:"+ name +" roll:"+ roll + " Address:"+ Address + " Branch:"+ Branch + " Grade:" + grade +"per:"+per);
}
public static void main(String[] args) {
School_pQ1 ob1= new School_pQ1() ;
ob1.getData("gopal",4,"Delhi","Cse",64,80,95,68);
ob1.rollNum();
ob1.putData();
School_pQ1 ob2= new School_pQ1() ;
ob2.getData("siva",12,"Delhi","Cse",45,60,35,20);
ob2.rollNum();
ob2.putData();
}
}