How do I do the jungle camping code coach? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How do I do the jungle camping code coach?

I've been trying to get this but I can't figure out how to take and process a random number of inputs.

1st Jan 2021, 11:38 AM
Yaye
Yaye - avatar
10 Answers
+ 5
Yaye Hint convert string input to string array. And use Equals method to compare string You can't compare with == Print the value if string is matching. string s1 = Console.ReadLine(); string[] arr = s1.Split(" "); for (int i = 0; i < arr.Length; i++) { if (arr[i].Equals("Grr")) Console.Write("Lion "); else if (arr[i].Equals("Rawr")) Console.Write("Tiger "); else if(arr[i].Equals("Ssss")) Console.Write("Snake "); else if(arr[i].Equals("Chirp")) Console.Write("Bird "); }
1st Jan 2021, 12:48 PM
A͢J
A͢J - avatar
+ 10
I Am AJ ! , in the microsoft docs you can find this: By default, the most common operations for string comparison are: ▪︎String.Equality and String.Inequality, that is, equality operators == and !=, respectively ▪︎String.CompareTo() ▪︎String.Equals() so for me there is no good or bad between these variants.
1st Jan 2021, 7:20 PM
Lothar
Lothar - avatar
+ 9
Yaye , before we can help you, you should show us your attempt first. if you have not done a try by yourself upto now, please do so. Put your code in playground and link it here. Thanks!
1st Jan 2021, 11:56 AM
Lothar
Lothar - avatar
+ 9
I Am AJ ! , just a comment to your posts: ▪︎you mentioned " ... use Equals method to compare string. You can't compare with ==" --->>> this statement is not true, you can use also "==" to compare strings: .... if (arr[i] == "Grr") .... is also working perfect.
1st Jan 2021, 7:04 PM
Lothar
Lothar - avatar
+ 3
Lothar It will work but it's bad checking. I don't know in C# but if you talk about Java, Sonar is a tool which tells don't compare string with == always use equals method.
1st Jan 2021, 7:12 PM
A͢J
A͢J - avatar
+ 1
Thanks AJ. Thanks to you I was able to do it
1st Jan 2021, 2:16 PM
Yaye
Yaye - avatar
+ 1
Yaye == compares object and two objects can't be same. Equals compare values.
1st Jan 2021, 4:18 PM
A͢J
A͢J - avatar
0
And what's the difference between "==" and ". Equals"
1st Jan 2021, 2:17 PM
Yaye
Yaye - avatar
0
Oh okay, cool thanks
1st Jan 2021, 5:16 PM
Yaye
Yaye - avatar