In a school, there are 4 different sections. in each section there are 40
students who have appeared for icse examinations.write a program to input percentage marks of each student of each section. calculate and display the number of students of each section, securing 95% and above in the council examination.
Answers
Answer:
import java.util.*;
public class Main
{
public static void main(String[] args) {
ArrayList<Double> A = new ArrayList<>();
ArrayList<Double> B = new ArrayList<>();
ArrayList<Double> C = new ArrayList<>();
ArrayList<Double> D = new ArrayList<>();
int a = 0 , b = 0 , c = 0 , d = 0;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the percentage of all 40 students in section A-");
for(int i = 0; i < 40; i++){
double x = sc.nextDouble();
A.add(x);
if(A.get(i) >= 95){
a++;
}
}
System.out.println("Enter the percentage of all 40 students in section B-");
for(int i = 0; i < 40; i++){
double x = sc.nextDouble();
B.add(x);
if(B.get(i) >= 95){
b++;
}
}
System.out.println("Enter the percentage of all 40 students in section C-");
for(int i = 0; i < 40; i++){
double x = sc.nextDouble();
C.add(x);
if(C.get(i) >= 95){
c++;
}
}
System.out.println("Enter the percentage of all 40 students in section D-");
for(int i = 0; i < 40; i++){
double x = sc.nextDouble();
D.add(x);
if(D.get(i) >= 95){
d++;
}
}
System.out.println("In section A out of 40 students " + a + " students secured above 95%");
System.out.println("In section B out of 40 students " + b + " students secured above 95%");
System.out.println("In section C out of 40 students " + c + " students secured above 95%");
System.out.println("In section D out of 40 students " + d + " students secured above 95%");
System.out.println("Out of 160 students in all 4 sections " + (a+b+c+d) + " secured above 95%");
}
}
Explanation: