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

bookChallenge: Method with Parameters

Opgave

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 alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 6. Kapitel 7
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

close

bookChallenge: Method with Parameters

Stryg for at vise menuen

Opgave

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 desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 6. Kapitel 7
single

single

some-alt