Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 11
import java.util.*; public class Program { public static void main(String[] args) { Scanner sc=new Scanner(System.in); StringTokenizer st=new StringTokenizer(sc.nextLine()); while(st.hasMoreTokens()) { switch(st.nextToken()) { case "Rawr": System.out.print("Tiger "); break; case "Grr": System.out.print("Lion "); break; case "Ssss": System.out.print("Snake "); break; case "Chirp": System.out.print("Bird "); break; } } } }
9th Jan 2020, 4:35 PM
Saroj Patel
Saroj Patel - avatar
+ 9
import java.util.*; public class Program { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String in=sc.nextLine(); String[] arrs=in.split(" "); int i=0; for(i=0;i<arrs.length;i++){ switch(arrs[i]){ case "Grr":System.out.print("Lion "); break; case "Rawr":System.out.print("Tiger "); break; case "Ssss":System.out.print("Snake "); break; case "Chirp":System.out.print("Bird "); break; } } } }
9th Jan 2020, 4:36 PM
Saroj Patel
Saroj Patel - avatar
+ 9
both code are working
9th Jan 2020, 4:37 PM
Saroj Patel
Saroj Patel - avatar
+ 2
Hint: * If <sound> contains "Grr" then replace all "Grr" in <sound> with <l>. * Lookup for String.Contains and String.Replace method reference Good luck! 👍
8th Jan 2020, 8:54 AM
Ipang
+ 1
Or use Console.Write("animal "). Task checker pass extra spaces at the end of line
8th Jan 2020, 8:57 AM
Igor Kostrikin
Igor Kostrikin - avatar
+ 1
https://code.sololearn.com/cC59O44NZHXj/#cs string[] sesler = {"Rawr", "Grr", "Ssss", "Chirp"}; string[] hayvanlar = {"Tiger","Lion","Snake","Bird"}; string upcomingVoices = Console.ReadLine(); string[] voices = upcomingVoices.Split(' '); foreach( string voice in voices) { switch(voice) { case "Rawr": Console.Write("Tiger "); break; case "Grr": Console.Write("Lion "); break; case "Ssss": Console.Write("Snake "); break; case "Chirp": Console.Write("Bird "); break; } }
10th Feb 2020, 10:13 PM
Şükrü Berkay
Şükrü Berkay - avatar
0
You need to output some animals into one line
8th Jan 2020, 8:44 AM
Igor Kostrikin
Igor Kostrikin - avatar
0
Пример есть в описании задачи
8th Jan 2020, 8:50 AM
Igor Kostrikin
Igor Kostrikin - avatar