Skip to content

Commit 4c60a93

Browse files
committed
feat: Calculate average of three subject marks and assign grade based on range
🧠 Logic: - Reads marks for three subjects (m1, m2, m3). - Computes the average of the marks. - Determines grade based on average: - ≥70 → Grade A - 60–69 → Grade B - 50–59 → Grade C - 40–49 → Grade D - <40 → Grade E Signed-off-by: Somesh diwan <[email protected]>
1 parent dc39116 commit 4c60a93

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
/*
22
Find grades for given marks.
33
m1, m2, m3 marks of three marks subjects.
4-
total and average.
5-
ave>=70 garde "A" and so on. check conditional statement below
4+
5+
total and average. avg>=70 garde "A" and so on.
66
*/
77

88
import java.util.Scanner;
99

1010
public class ConditionalStatementsAB5 {
1111
public static void main(String[] args) {
1212
Scanner scanner = new Scanner(System.in);
13-
1413
int m1, m2, m3;
1514

1615
System.out.println("Enter a mark of subjects: ");
@@ -20,11 +19,11 @@ public static void main(String[] args) {
2019
m3=scanner.nextInt();
2120

2221
float avg = (float) (m1+m2+m3)/3;
22+
2323
if (avg>=70){
2424
System.out.println("You have obtain Grade A");
2525
}
26-
else if (avg >= 60 && avg < 70)
27-
{
26+
else if (avg >= 60 && avg < 70) {
2827
System.out.println("You have obtain garde B");
2928
} else if (avg>=50 && avg <60) {
3029
System.out.println("You have obtain garde C");
@@ -35,4 +34,4 @@ else if (avg >= 60 && avg < 70)
3534
System.out.println("Garde E");
3635
}
3736
}
38-
}
37+
}

0 commit comments

Comments
 (0)