Page 284 - Computer science 868 Class 12
P. 284

The output of the preceding program is as follows:
              Input for p[] :
              Enter Number :5
              Enter Number :3
              Enter Number :4
              Enter Number :6
              Enter Number :1
              Enter Number :2
              Input for q[] :
              Enter Number :8
              Enter Number :23
              Enter Number :34
              Enter Number :25
              5, 3, 4, 6, 1, 5, 3, 4, 6, 1, 2, 8, 23,


                Program 3      Write a program to accept the marks in Physics, Chemistry and Computer Science secured by
                               5 students of a class in a single-dimensional array. Find and display the following:
                                i.  Number of students securing 80% and above in aggregate.
                               ii.  Number of students securing 30% and below in aggregate.

                 1       import java.util.*;
                 2       class Average

                 3       {
                 4           public static void main()

                 5           {
                 6               Scanner in = new Scanner(System.in);

                 7               int i,c1=0, c2=0;
                 8               int phy[] = {70,89,56,87,90};

                 9               int chem[] = {99,89,98,78,86};
                10               int cs[] = {40,67,98,90,79};

                11
                12               for(i=0;i<5;i++)

                13               {
                14                   if((phy[i]+chem[i]+cs[i])/3.0 >=80)

                15                       c1++;
                16
                17                   if((phy[i]+chem[i]+cs[i])/3.0 <=34)

                18                       c2++;

                19               }
                20               System.out.println("Number of students getting 80% and above : "+c1);



                282282  Touchpad Computer Science-XII
   279   280   281   282   283   284   285   286   287   288   289