Computer Science, asked by sriram28324, 2 months ago

write the input using scanner object and if statement to count the number of senior citizens visiting the exhibition hall where name and age are given as input

Answers

Answered by atrs7391
0

Here is your program:

package com.company;

import java.util.Scanner;

class Main

{

   public static void main(String[] args) {

       Scanner sc = new Scanner(System.in);

       int n=0;

       int infi = 1;

       while (infi%2==1) {

           System.out.println("Enter age of the person: ");

           int a = sc.nextInt();

           System.out.println("Enter Name of the person: ");

           sc.nextLine();

           sc.nextLine();

           if (a>=60){

               n=n+1;

           }

           System.out.println("Enter 1 (/odd numbers to take input again)");

           System.out.println("Enter 2 (/odd numbers to show the total number of senior citizens");

           int n2 = sc.nextInt();

           infi = n2;

       }

       System.out.println("Total number of Senior citizens visited the exhibition hall: "+n);

   }

}

Similar questions