ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2009 ICSE Computer Science Paper



Share with a Friend

Solved 2009 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

Exam Results Program - ICSE 2009 Computer Science

The annual examination results of 50 students in a class is tabulated as follows:

Roll No. Subject A Subject B Subject C
…….. …….. …….. ……..

Write a program to read the data, calculate and display the following:
a) Average marks obtained by each student.
b) Print the roll number and average marks of the students whose average mark is above 80.
c) Print the roll number and average marks of the students whose average mark is below 40.

import java.util.Scanner; class Students{ public static void main(String args[]){ Scanner in = new Scanner(System.in); int roll[] = new int[50]; int a[] = new int[50]; int b[] = new int[50]; int c[] = new int[50]; double avg[] = new double[50]; for(int i = 0; i < a.length; i++){ System.out.print("Roll: "); roll[i] = Integer.parseInt(in.nextLine()); System.out.print("Subject A marks: "); a[i] = Integer.parseInt(in.nextLine()); System.out.print("Subject B marks: "); b[i] = Integer.parseInt(in.nextLine()); System.out.print("Subject C marks: "); c[i] = Integer.parseInt(in.nextLine()); avg[i] = (a[i] + b[i] + c[i]) / 3.0; } System.out.println("Roll\tAverage"); for(int i = 0; i < a.length; i++) System.out.println(roll[i] + "\t" + avg[i]); System.out.println("Students with average > 80"); for(int i = 0; i < a.length; i++){ if(avg[i] > 80) System.out.println(roll[i] + "\t" + avg[i]); } System.out.println("Students with average < 40"); for(int i = 0; i < a.length; i++){ if(avg[i] < 40) System.out.println(roll[i] + "\t" + avg[i]); } } }

Output

 
 OUTPUT : 
Roll: 1
Subject A marks: 45
Subject B marks: 56
Subject C marks: 67
Roll: 2
Subject A marks: 98
Subject B marks: 87
Subject C marks: 76
Roll: 3
Subject A marks: 65
Subject B marks: 78
Subject C marks: 45
Roll: 4
Subject A marks: 65
Subject B marks: 78
Subject C marks: 80
Roll: 5
Subject A marks: 34
Subject B marks: 43
Subject C marks: 45
Roll    Average
1          56.0
2          87.0
3          62.666666666666664
4          74.33333333333333
5          40.666666666666664

Students with average > 80
2   87.0
Students with average < 40