0
0
Kotlinprogramming~15 mins

Comparison operators in Kotlin - Mini Project: Build & Apply

Choose your learning style9 modes available
Comparison Operators in Kotlin
📖 Scenario: You are helping a store manager compare product prices to decide which items are cheaper or more expensive.
🎯 Goal: Build a Kotlin program that compares two product prices using comparison operators and shows the results.
📋 What You'll Learn
Create two variables with exact prices
Create a variable to hold a threshold price
Use comparison operators to compare prices with the threshold
Print the comparison results clearly
💡 Why This Matters
🌍 Real World
Comparing prices helps shoppers and store managers decide which products are cheaper or more expensive.
💼 Career
Understanding comparison operators is essential for decision-making logic in software development.
Progress0 / 4 steps
1
Create product price variables
Create two variables called priceA and priceB with values 150 and 200 respectively.
Kotlin
Need a hint?

Use val to create variables and assign the exact numbers.

2
Add a threshold price variable
Create a variable called threshold and set it to 180.
Kotlin
Need a hint?

Use val threshold = 180 to create the variable.

3
Compare prices with threshold
Create two Boolean variables called isPriceALess and isPriceBMore. Set isPriceALess to the result of priceA < threshold and isPriceBMore to the result of priceB > threshold.
Kotlin
Need a hint?

Use < and > operators to compare values.

4
Print the comparison results
Print the values of isPriceALess and isPriceBMore using two separate println statements.
Kotlin
Need a hint?

Use println(isPriceALess) and println(isPriceBMore) to show the results.