Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Method with Parameters | Section
C# Basics
Sectionย 1. Chapterย 55
single

single

bookChallenge: Method with Parameters

Swipe to show menu

Task

Swipe to start coding

In this task, you will practice creating a method with multiple parameters that performs a calculation and returns a result.

  • Create a method CalculateFinalPrice that:
    • Accepts three parameters:
      • itemPrice (double)
      • quantity (int)
      • discount (double)
    • Calculates the total price: total = itemPrice * quantity.
    • Applies the discount: finalTotal = total - (total * discount / 100).
    • Returns the finalTotal as a double.
  • In Main, call CalculateFinalPrice with example values and print the result using Console.WriteLine.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Sectionย 1. Chapterย 55
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt