-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJungleCamping.java
More file actions
35 lines (35 loc) · 1.01 KB
/
Copy pathJungleCamping.java
File metadata and controls
35 lines (35 loc) · 1.01 KB
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
/*You are given the noises made by different animals that you can hear in the dark, evaluate each noise to determine which animal it belongs to. Lions say 'Grr', Tigers
say 'Rawr', Snakes say 'Ssss', and Birds say 'Chirp'.
Sample Input:
Rawr Chirp Ssss
Sample Output:
Tiger Bird Snake
*/
import java.util.Scanner;
public class JungleCamping{
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
String voices = in.nextLine();
voices = voices.toLowerCase();
String words[] = voices.split("\\s+");
String output[] = new String[50];
for (int i=0; i<words.length; i++) {
switch (words[i]) {
case "grr": output[i]="Lion";
break;
case "rawr": output[i]="Tiger";
break;
case "ssss": output[i]="Snake";
break;
case "chirp": output[i]="Bird";
break;
default: break;
}
}
for (int i=0; i<output.length;i++ ) {
if (output[i]!=null) {
System.out.print(output[i]+" ");
}
}
}
}