You have the following code:
fun main() {
var validationResult = false
var password: String
while (!validationResult) {
var password = readln()
validationResult = password.length > 4
if (!validationResult) {
println("Your password should be five or longer characters, please write a new password")
}
}
println("Good password")
}This program asks for a password, and if it is shorter than 5 characters, it asks again until it receives a password of 5 or longer.
We need to decompose the program to the functions validatePassword() and main(). You already have the main() function.
Your task is to write a password length check in the validatePassword() function. If the password is less than 5 characters, print "Your password should be five or longer characters, please write a new password" and return false as the result of the function.
If the password is 5 characters or longer, print "Good password" and return true.