Input marks in three subjects. Calculate average marks and then give division as per following conditions : Avg marks Division > 60 I 50-60 II 2 35-50 III < 35 0
Answers
import java.util.*;
class HelloWorld {
public static void main(String[] args) {
double marks , total = 0.0;
double[] grade = new double[3];
Scanner scanner = new Scanner(System.in);
for(int i = 0; i < 3; i++)
{
System.out.print("Enter marks of subject" + (i+1) + ": ");
double d = scanner.nextDouble();
grade[i] = d;
total = total + grade[i];
}
double average = total / 3;
if(average >= 60)
{
System.out.println("Division 1");
}
else if(average >= 50 && average <= 60)
{
System.out.println("Division 2");
}
else if(average >= 35 && average <= 50)
{
System.out.println("Division 3");
}
else
{
System.out.println("Division 4");
}
}
}Answer:
Explanation: