Question: both in kotlin plz Write a method csvSum that accepts a single String as input and returns the sum of the comma-separated values that it
both in kotlin plz
Write a method csvSum that accepts a single String as input and returns the sum of the comma-separated values that it contains as an Int. For example, given the String "1,2,4", you would return 7. Note that the values may be surrounded by whitespace, which you should ignore. So given " 1, 2 ,4 ", you would still return 7.
You can assume that passed Strings will contain a valid input, specifically comma-separated values that you can convert to Ints. You will probably want to use Kotlin Strings toInt method to convert them to Ints:
and another question is
Write a method named stringHasBothCharacters that accepts a single String and two Chars and returns whether both characters appear at least once in the String. For example, given the String aabbcc and the characters a and b you would return true, but given c and d you would return false.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
