Skip to content

Instantly share code, notes, and snippets.

@mattiaferigutti
Created May 29, 2021 12:51
Show Gist options
  • Save mattiaferigutti/5610b9b3c1d091be0f59c034b2d9c2fd to your computer and use it in GitHub Desktop.
Save mattiaferigutti/5610b9b3c1d091be0f59c034b2d9c2fd to your computer and use it in GitHub Desktop.
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