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
- Assign the product price
1000to thepricevariable - Assign the tax rate
0.1to thetaxRatevariable - Copy the value of
pricetobasePricevariable - Calculate and assign the tax amount:
tax = basePrice * taxRate - Calculate and assign the total:
total = basePrice + tax - 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?
