Days difference

Report a typo

The function howManyDays(year1: Int, month1: Int, day1: Int, year2: Int, month2: Int, day2: Int) gets the data for two dates as parameters: (year1, month1, day1) and (year2, month2, day2), respectively. It returns an integer number that denotes the days difference between them.

If the second date occurs after the first, then the returned valued is a positive number, while if the first date occurs after the second, the number is negative.

Write the correct code for the howManyDays() function.

Sample Input 1:

2001 1 1
2000 1 1

Sample Output 1:

-366
Write a program in Kotlin
import kotlinx.datetime.*

fun howManyDays(year1: Int, month1: Int, day1: Int, year2: Int, month2: Int, day2: Int): Int {
// Write your code here

//
}

fun main() {
val (year1, month1, day1) = readln().split(" ").map { it.toInt() }
val (year2, month2, day2) = readln().split(" ").map { it.toInt() }

println(howManyDays(year1, month1, day1, year2, month2, day2))
}
___

Create a free account to access the full topic