0

i need the code if i give grr grr it will show lion lion as input. But it shows no output.

https://code.sololearn.com/cvYamhp2I2ow/?ref=app

6th May 2020, 6:28 PM
Harithra Shanmugam
5 Réponses
0
Harithra Shanmugam Here is my attempt you can do it with many other ways also. https://code.sololearn.com/cOSAxfzP2rw5/?ref=app
6th May 2020, 7:24 PM
Muhammad Bilal
Muhammad Bilal - avatar
+ 1
Store the grr and grr or so inputs in array ,then run a for loop and pass the switch(array[i])
6th May 2020, 7:01 PM
Abhay
Abhay - avatar
+ 1
If you use loop then you have to use "if statement" to compare , the line of code will get increase. As know that in "if else statement" we are checking the condition ,in "switch" we are checking exact match with "case".
6th May 2020, 7:07 PM
Dasarath Singh
+ 1
That's why passing that case as Suppose For(i=0;i<arr.length;i++){ Switch(arr[i]) Case: } ,works fine according to me but I didn't tired so I can't say much,
6th May 2020, 7:16 PM
Abhay
Abhay - avatar
0
In switch case it will match the exact value of "n" with the case. switch(n) { case "Grr": case "grr": System.out.print("Lion"); break ; }
6th May 2020, 6:56 PM
Dasarath Singh