セクション 1. 章 5
single
Challenge: Understanding Variable Scopes
メニューを表示するにはスワイプしてください
タスク
スワイプしてコーディングを開始
You are building a simple tax calculator. Each user has a salary, and you want to calculate the amount of tax they need to pay based on a fixed tax rate.
- Declare the function
calculateTaxthat returns adouble. - Add a parameter to the function with type
doublenamedsalary. - Calculate the tax by multiplying
salarybytaxRate. Usedouble taxRate = 0.18as the fixed rate. - Return the calculated tax from the function.
Do not modify the value of taxRate inside the calculateTax function.
Example
calculateTax(2500.0) → 450.0
calculateTax(1000.0) → 180.0
calculateTax(0) → 0.0
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 1. 章 5
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください