Solved tasks for Kotlin lessons 1-2

The following exercises will help you put your knowledge of Kotlin to the test. Based off of what you've learned from previous lessons. Try to solve them on your own, but know that you could always download the working solutions under the article. Nonetheless, beware that when you view the solution without solving the exercise, you won't learn anything :)

If you find yourself stuck at some point, you should always try going back to check previous tutorials first and figure the problem out by yourself.

Easy exercise

Create an application which will ask for a username and then for an ability. Then the program will print "name is ability", see image below.

The application screen sample:

Hi, what is your name?
Bill Gates
What are you like?
ultraepic rich
Bill Gates is ultraepic rich

Intermediate exercise

Create an application which will ask for an integer and prints its second power (x squared).

The application screen sample:

Enter a number, and I'll square it:
Result: 4096

Advanced exercise

Create an application that will ask for a circle's radius. Then print its circumference and its area.

The application screen sample:

Enter the circle's radius (cm):
The circle's circumference based on the given radius is: 75.98800239562989 cm
Area of the circle is: 459.7274289871221 cm^2


Did you have a problem with anything? Download the sample application below and compare it with your project, you will find the error easily.


By downloading the following file, you agree to the license terms

Downloaded 49x (23.57 kB)
Application includes source codes in language Kotlin


Previous article
Variables, type system and parsing in Kotlin
All articles in this section
Kotlin Basic Constructs
Article has been written for you by Samuel Kodytek
Do you like this article?
1 votes
I'm intereseted in JVM languages and Swift




Yonatan Myers
Yonatan Myers:10/8/2018 16:13
fun main(args: Array<String>) {
    println("Hi, what is your name? ")
    val name = readLine()!!

    println("What are you like? ")
    val like = readLine()!!

    println("$name is $like")
10/8/2018 16:13
To maintain the quality of discussion, we only allow registered members to comment. Sign in. If you're new, Sign up, it's free.

1 messages from 1 displayed.