Computer Science, asked by koiralapramish, 4 days ago

Write a QBASIC program for the following :

(a) Write a program that reads ten numbers from the list of numbers and displays the sum of even numbers of them. The list of numbers contains : 4,2,3,7,18,41,36

(b) Write a program to find the frequency of data divisible by 3 and 5 among the data given as : 15,12,14,30,45,36,42 and 60.

Answers

Answered by samarthkrv
0

Answer:

1)

import java.util.*;

public class Main

{

public static void main(String[] args) {

    int sum = 0;

 int[] arr = {4,2,3,7,18,41,36};

 ArrayList<Integer> list = new ArrayList<Integer>();

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

         list.add(arr[i]);

     }

     for(int i = 0; i < list.size();i++){

         if(i%2 == 0){

             sum = sum + list.get(i);

         }

     }

     System.out.println("between the list the count of numbers the sum of even numbers is: " + sum);

}

}

2)

import java.util.*;

public class Main

{

public static void main(String[] args) {

    ArrayList<Integer> list = new ArrayList<Integer>();

    int frequency = 0;

    int[] arr = {15,12,14,30,45,36,42,60};

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

            if(arr[i]%3==0 && arr[i]%5 == 0){

                frequency++;

                list.add(i);

            }

        }

        System.out.println("The frequency of numbers being divisible by 3 and 5 is: " + frequency);

        System.out.println("Those numbers are:");

        for (int x : list){

            System.out.println(x);

        }

}

}

Explanation:

Similar questions