Computer Science, asked by Jahnavii1, 11 months ago

Answer the 7th question, given in the attachment
The program must be in java language​

Attachments:

Answers

Answered by prashantrohilla32
2

Answer:       public class Main

{

public static void main(String[] args) {

   

    String []sports=

    {"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"tennis","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

   ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball","tennis"

    ,"badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball","tennis"

    ,"badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball","tennis"

     ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball","tennis"

    ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball","tennis"

    ,"badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball","tennis"

    ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball","tennis"

    ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"

    ,"cricket","badminton","hockey","football","basketball","tennis","badminton","hockey","football","basketball"};

   

    int a=0;

 int b=0;

       String c="cricket";

       String t="tennis";

  System.out.println("Total number of games choosen by students = "+sports.length);

 for(int i=0;i<sports.length;i++)

 {

 if(sports[i]==c)

     {

     a=a+1;

     }

 }

  System.out.println("Number of students whose favourite game is Cricket =" +a);

 

 for(int i=0;i<sports.length;i++)

 {

 if(sports[i]==t)

      {

     b=b+1;

     }

 }

      System.out.println("Number of students whose favourite game is Tennis = "+b);

}

}

Explanation: run this program in online java compiler at onlinegdb.com

i have already entered 300 random games.

Attachments:
Similar questions