The sameNumber method checks to see if the number of words in the phrase, numwords, is the same number of words contained in the myWords array. The method returns true of the array and phrase have the same number of words and false if they do not. Write the sameNumber method.

Respuesta :

Answer:

Answered below.

Explanation:

//Program is written in Kotlin programming language.

fun sameNumber(numWords: String, myWords: List<String>) : Boolean{

//Split words in phrase into list

val str: List<String> = numWords.split(" ")

//Convert to mutable list.

val phrase = str.toMutableList()

val words = myWords.toMutableList()

//Compare the number of items in each list.

if( phrase.size == words.size){

return true

}else{

return false

}

}