Created
May 29, 2021 12:51
-
-
Save mattiaferigutti/5610b9b3c1d091be0f59c034b2d9c2fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package starting | |
fun main() { | |
checkNegativeNumber(12.4f) | |
checkSumNumber() | |
val marco = Person("Marco", "Rossi", 23) | |
marco.age = 12 | |
println(marco.getFormattedFullName()) | |
} | |
fun checkNegativeNumber(number: Float) { | |
when { | |
number < 0.0 -> { | |
println("$number is a negative number.") | |
} | |
number > 0.0 -> println("$number is a positive number.") | |
else -> println("$number is 0.") | |
} | |
} | |
fun checkSumNumber() { | |
val num = 10 | |
var sum = 0 | |
for (i in 1..num) { | |
// sum = sum+i; | |
sum += i | |
} | |
println("Sum = $sum") | |
} | |
class Person( | |
val name: String, | |
val surname: String, | |
var age: Int | |
) { | |
fun getFormattedFullName() = "$name $surname".toUpperCase() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment