-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask2
More file actions
64 lines (52 loc) · 1.31 KB
/
Copy pathtask2
File metadata and controls
64 lines (52 loc) · 1.31 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
import java.util.Scanner;
class extra{
public int divi( int n, int sum) {
int s = sum;
int d;
if ((s % n) > n) {
return d = ((s % n) / n);
}
else if ((s % n) < n)
{
return d = ((s % n) * 10 / n);
}
return s;
}
public String grade(double per)
{
String g;
if(per>90)
g="A";
else if (per>80&&per<90)
g="B";
else if (per>70&&per<80)
g="C";
else if (per>60&&per<70)
g="D";
else
g="E";
return g;
}
}
public class task2
{
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
extra ex =new extra();
int sum=0;
System.out.print("Enter your no. of subjects: ");
int n = sc.nextInt();
int[] marks = new int[n];
for (int i = 0; i < n; i++) {
System.out.print("Enter your marks in subject " + (i + 1));
marks[i] = sc.nextInt();
sum=sum+marks[i];
}
int avg=sum/n;
int deci=(ex.divi(n,sum))/100;
double per=(avg+deci);
System.out.println(per);
String grd=ex.grade(per);
System.out.println("your total maarks is: "+sum+" your average percentage is: "+per+" your grade is: "+grd);
}
}