Challenge: Method with Parameters
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
CalculateFinalPricethat:- 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
finalTotalas adouble.
- Accepts three parameters:
- In
Main, callCalculateFinalPricewith example values and print the result usingConsole.WriteLine.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 6. ChapterΒ 5
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 1.67
Challenge: 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
CalculateFinalPricethat:- 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
finalTotalas adouble.
- Accepts three parameters:
- In
Main, callCalculateFinalPricewith example values and print the result usingConsole.WriteLine.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 6. ChapterΒ 5
single