-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathJungleCamping.java
More file actions
35 lines (26 loc) · 840 Bytes
/
JungleCamping.java
File metadata and controls
35 lines (26 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.Scanner;
import java.util.HashMap;
public class JungleCamping {
static HashMap<String, String> noiseToAnimal = new HashMap<String, String>() {
{
put("Rawr", "Tiger");
put("Chirp", "Bird");
put("Ssss", "Snake");
put("Grr", "Lion");
}
};
public static String getAnimals(String noises) {
String[] noisesSplit = noises.split(" ");
StringBuilder animals = new StringBuilder();
for (String noise : noisesSplit) {
animals.append(noiseToAnimal.get(noise)).append(" ");
}
return animals.toString().trim();
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String noises = input.nextLine();
System.out.println(getAnimals(noises));
input.close();
}
}