
Step 1: Understand the requirement of the question.
In this question, we have to store the designations of \(100\) employees in a one-dimensional array. After storing all the designations, we need to accept one designation from the user and count how many times that designation appears in the array. Finally, we print that total count.
Step 2: Declare the required variables and array.
We need a string array to store the designations of \(100\) employees. We also need one variable to store the designation entered by the user for searching, and one counter variable to count the number of matches.
Step 3: Accept the designations of 100 employees.
Using a loop, we input all \(100\) designations one by one and store them in the array. Since designations are words such as Manager, Trainee, Director, etc., we use a String array.
Step 4: Search the given designation in the array.
After taking the input designation to be searched, we traverse the array again. Every time the entered designation matches an element of the array, we increase the counter by \(1\). For string comparison in Java, we use the equalsIgnoreCase() method so that the comparison works properly even if the user enters the designation in a different letter case.
Step 5: Display the final result.
At the end of the loop, the counter contains the total number of employees having the required designation. This value is then printed as the output.
Step 6: Write the complete Java program.
import java.util.Scanner;
class EmployeeDesignation
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
String desig[] = new String[100];
String search;
int i, count = 0;
for(i = 0; i < 100; i++)
{
System.out.print("Enter designation of employee " + (i + 1) + ": ");
desig[i] = sc.nextLine();
}
System.out.print("Enter designation to be searched: ");
search = sc.nextLine();
for(i = 0; i < 100; i++)
{
if(desig[i].equalsIgnoreCase(search))
{
count++;
}
}
System.out.println("Total number of employees = " + count);
}
}Step 7: Explain the example given in the question.
For example, if the designations stored are Trainee, Manager, Chef, Manager, Director, Manager and the input designation is Manager, then the word Manager appears \(3\) times. Therefore, the output will be \(3\).

Give the output of the following Java program segment:
String a[] = {"Atasi", "Aditi", "Anant", "Amit", "Ahana"};
System.out.println(a[1].charAt(1) + "*" + a[2].charAt(2));
The output of the above statement is:
Assertion (A): The substring() method modifies the original String.
Reason (R): The substring() method can extract part of a String from a specific index.
Rewrite the following program segment using a for loop:
Given program segment:
int a = 5, b = 10;
while (b > 0)
{
b -= 2;
}
System.out.println(a * b);
Note: Ensure that the variable $b$ remains accessible for the System.out.println statement after the loop terminates.
Define a class named StepTracker with the following specifications:
Member Variables:
String name — stores the user's name.int sw — stores the total number of steps walked ($sw$).double cb — stores the estimated calories burned ($cb$).double km — stores the estimated distance walked in kilometers ($km$).Member Methods:
1. void accept()
To input the name and the sw (steps walked) using Scanner class methods only.
2. void calculate()
Calculates calories burned ($cb$) and distance in ($km$) based on steps walked ($sw$) using the provided estimation logic.