We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String[] Name = new String[n];
for (int i = 0; i < n; i++) {
Name[i] = sc.next();
}
int S_count = 0;
int R_count = 0;
int H_count = 0;
for (int i = 0; i < n; i++) {
if (Name[i].equals("Student")) {
S_count++;
} else if (Name[i].equals("Rockstar")) {
R_count++;
} else if (Name[i].equals("Hacker")) {
H_count++;
}
}
System.out.println(S_count + " " + R_count + " " + H_count);
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Instanceof keyword
You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.;
public class Solution {
}