kotlin question Array ...... | Sololearn: Learn to code for FREE!

+1

kotlin question Array ......

Day of the Week The given program declares an array of weekday names. You need to take a number as input and output the name of the day at that index. In case the input is out of the range, output "Invalid day". Sample Input: 2 Sample Output: Tuesday here is my Answer fun main(args: Array<String>) { val names = arrayOf("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") val day = readLine()!!.toInt() if (day >= 0) { println(names[day]) } } it passed all the test except the Fifth Test...... please help me to fix this ........

5/1/2021 9:34:01 AM

Abhishek Biswas

1 Answer

New Answer

+3

Hi! you don't have a valid input check for a given range, and what should your program output if the data is out of bounds? read the task carefully again