InterviewSolution
| 1. |
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 |
|
Answer» 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); } } |
|