0
0
Kotlinprogramming~15 mins

Arithmetic operators in Kotlin - Mini Project: Build & Apply

Choose your learning style9 modes available
Arithmetic Operators in Kotlin
📖 Scenario: You are helping a small shop owner calculate prices and discounts for products.
🎯 Goal: Build a Kotlin program that uses arithmetic operators to calculate the total price after discount and tax.
📋 What You'll Learn
Create variables for product price and discount percentage
Create a variable for tax rate
Calculate the discounted price using subtraction and multiplication
Calculate the final price by adding tax
Print the final price
💡 Why This Matters
🌍 Real World
Calculating prices with discounts and taxes is common in shopping and billing systems.
💼 Career
Understanding arithmetic operators is essential for any programming job that involves calculations or data processing.
Progress0 / 4 steps
1
Create product price and discount variables
Create a Double variable called productPrice and set it to 100.0. Create another Double variable called discountPercent and set it to 15.0.
Kotlin
Need a hint?

Use val to create variables and assign the exact values given.

2
Add tax rate variable
Add a Double variable called taxRate and set it to 8.0 to represent 8% tax.
Kotlin
Need a hint?

Remember to use val and assign the exact value 8.0.

3
Calculate discounted price and final price
Create a Double variable called discountedPrice that calculates the price after discount using subtraction and multiplication. Then create a Double variable called finalPrice that adds tax to the discounted price using multiplication and addition.
Kotlin
Need a hint?

Use arithmetic operators -, *, /, and + to calculate prices.

4
Print the final price
Write a println statement to display the finalPrice variable.
Kotlin
Need a hint?

Use println(finalPrice) to show the result.