001-005-009

Chain Calculation Program

Hard

Problem Description

Chain Calculation Program

Learning Objective: Understand how to chain variable assignments and pass calculation results to subsequent variables

Overview

Create a program that calculates the tax-inclusive price of a product. Learn how to use multiple variables and pass calculation results to the next variable.

Specifications

  1. Assign the product price 1000 to the price variable
  2. Assign the tax rate 0.1 to the taxRate variable
  3. Copy the value of price to basePrice variable
  4. Calculate and assign the tax amount: tax = basePrice * taxRate
  5. Calculate and assign the total: total = basePrice + tax
  6. Output the result in the specified format

Output Format

Price: 1000
Base: 1000
Tax: 100.0
Total: 1100.0

Hints

  • When you copy a variable's value to another variable, you can perform calculations while preserving the original value
  • Calculation results can also be stored in variables

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?