Printing arguments

Report a typo

The program receives a string of 3 arguments from the console. For each argument, print the following:

"Argument number: argument. It has number_of_characters characters",

where number - number of argument, argument - the current argument, number_of_characters - a number of characters in the argument.

If the string contains less than 3 arguments or more than 3 arguments, output the following:

"Invalid number of program arguments".

Sample Program Arguments 1: "Knowledge" "Is" "Power"

Sample Output 1:

Argument 1: Knowledge. It has 9 characters
Argument 2: Is. It has 2 characters
Argument 3: Power. It has 5 characters

Sample Program Arguments 2: "Guard" "It" "Well"

Sample Output 2:

Argument 1: Guard. It has 5 characters
Argument 2: It. It has 2 characters
Argument 3: Well. It has 4 characters

Sample Program Arguments 3: "argument"

Sample Output 3:

Invalid number of program arguments
Write a program in Kotlin
fun main(args: Array<String>) {
TODO()
}
___

Create a free account to access the full topic