Computer Science, asked by op565656, 8 hours ago

an exhibition has 100 visitors of various age groups on a particular day write a java program to input age of visiotrs and display the frequency of the following age groups' below 12 years b 12-18 years c 19-40 years dd above 40

Answers

Answered by samarthkrv
3

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

 int a = 0 , b = 0 , c = 0 , d = 0;

 Scanner sc = new Scanner(System.in);

 System.out.println("Enter the ages of all 100 visitors");

     for(int i = 0; i < 100; i++){

         int age = sc.nextInt();

         if(age > 12){

             a++;

         }

         else if(age > 12 && age < 18){

             b++;

         }

         else if(age > 18 && age < 40){

             c++;

         }

         else if(age > 40){

             d++;

         }

     }

     System.out.println("Number of people below the age of 12 " + a);

     System.out.println("Number of people above 12 and below 18 " + b);

     System.out.println("Number of people above 19 and below 40 " + c);

     System.out.println("Number of people above 40 " + d);

}

}

Explanation:

Similar questions