Sektion 1. Kapitel 55
single
Challenge: 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
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.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 1. Kapitel 55
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat