Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Challenge: Method with Parameters | Metoder
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
C#-Grunder

bookChallenge: Method with Parameters

Uppgift

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.

Lösning

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 6. Kapitel 7
single

single

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

close

bookChallenge: Method with Parameters

Svep för att visa menyn

Uppgift

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.

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 6. Kapitel 7
single

single

some-alt