0
0
Kotlinprogramming~30 mins

Int, Long, Float, Double number types in Kotlin - Mini Project: Build & Apply

Choose your learning style9 modes available
Working with Int, Long, Float, and Double Number Types in Kotlin
📖 Scenario: You are creating a simple Kotlin program to store and display different types of numbers used in real life, such as counting items, measuring distances, or recording temperatures.
🎯 Goal: Build a Kotlin program that declares variables of type Int, Long, Float, and Double, assigns them specific values, and then prints these values.
📋 What You'll Learn
Create variables with exact names and values as instructed
Use Kotlin number types: Int, Long, Float, Double
Print the values exactly as shown
💡 Why This Matters
🌍 Real World
Number types like Int, Long, Float, and Double are used in apps to store counts, distances, prices, and measurements accurately.
💼 Career
Understanding these types helps you write programs that handle numbers correctly, which is essential for software development in finance, science, and many other fields.
Progress0 / 4 steps
1
Create Int and Long variables
Create a variable called countItems of type Int and set it to 150. Then create a variable called distanceInMeters of type Long and set it to 9876543210L.
Kotlin
Need a hint?

Remember to add L at the end of the Long value.

2
Create Float and Double variables
Create a variable called temperatureFloat of type Float and set it to 36.6F. Then create a variable called temperatureDouble of type Double and set it to 36.65.
Kotlin
Need a hint?

Remember to add F at the end of the Float value.

3
Use variables in expressions
Create a variable called totalTemperature of type Double that adds temperatureFloat and temperatureDouble. Use explicit conversion to Double for temperatureFloat.
Kotlin
Need a hint?

Use toDouble() to convert Float to Double before adding.

4
Print all variable values
Print the values of countItems, distanceInMeters, temperatureFloat, temperatureDouble, and totalTemperature each on a new line using println.
Kotlin
Need a hint?

Use println for each variable to print its value on a new line.