Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting the total count of the first letter  RSS feed

 
Joan Tan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming a user input a number of countries from a range between 1-10 and I want to get the total count of all the country with the same first letter. I used an string array to store all of the user input and a for loop to count but I'm not getting the correct output.

 
Liutauras Vilda
Marshal
Posts: 4647
318
BSD
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Let's take an example:
Spain
Italy
Serbia

Two countries starts with the same letter s. Now tell step by step, what your code does? Start from line 6. That should explain one problem. There are more.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!