0
0
R Programmingprogramming~15 mins

Arithmetic operators in R Programming - Mini Project: Build & Apply

Choose your learning style9 modes available
Arithmetic Operators in R
📖 Scenario: You are helping a small shop owner calculate prices and discounts using simple math operations in R.
🎯 Goal: Build a small R script that uses arithmetic operators to calculate total price, discount amount, and final price after discount.
📋 What You'll Learn
Create variables with exact numeric values
Use arithmetic operators: +, -, *, /
Assign results to new variables
Print the final result
💡 Why This Matters
🌍 Real World
Calculating prices, discounts, and totals is common in shops, restaurants, and online stores.
💼 Career
Basic arithmetic operations are essential for data analysis, finance, and programming tasks.
Progress0 / 4 steps
1
Create initial price variables
Create two variables in R called price_item1 and price_item2 with values 120 and 80 respectively.
R Programming
Need a hint?

Use the assignment operator <- to assign values to variables.

2
Calculate total price
Create a variable called total_price that adds price_item1 and price_item2 using the + operator.
R Programming
Need a hint?

Use total_price <- price_item1 + price_item2 to add the two prices.

3
Calculate discount amount
Create a variable called discount_rate with value 0.1 (10%). Then create a variable called discount_amount that multiplies total_price by discount_rate using the * operator.
R Programming
Need a hint?

Remember to assign discount_rate <- 0.1 and then multiply it with total_price.

4
Calculate final price and print
Create a variable called final_price that subtracts discount_amount from total_price using the - operator. Then print final_price using the print() function.
R Programming
Need a hint?

Use final_price <- total_price - discount_amount and then print(final_price).