Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Challenge: Understanding Variable Scopes | Introduction
C++ Functions

bookChallenge: Understanding Variable Scopes

Завдання

Swipe to start coding

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.

  1. Declare the function calculateTax that returns a double.
  2. Add a parameter to the function with type double named salary.
  3. Calculate the tax by multiplying salary by taxRate. Use double taxRate = 0.18 as the fixed rate.
  4. 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

Рішення

solution.cpp

solution.cpp

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 5
single

single

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Suggested prompts:

Can you explain this in simpler terms?

What are the main takeaways from this?

Can you give me an example?

close

Awesome!

Completion rate improved to 5

bookChallenge: Understanding Variable Scopes

Свайпніть щоб показати меню

Завдання

Swipe to start coding

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.

  1. Declare the function calculateTax that returns a double.
  2. Add a parameter to the function with type double named salary.
  3. Calculate the tax by multiplying salary by taxRate. Use double taxRate = 0.18 as the fixed rate.
  4. 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

Рішення

solution.cpp

solution.cpp

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 5
single

single

some-alt