Challenge: Scopes
Opgave
Swipe to start coding
You want to calculate total sales for a day using local and global variables.
- Declare a global variable
grandTotal(outside any method) to store the total sales. - Create a method
AddSalethat:- Declares local variables
priceandquantity. - Calculates the total for that sale and adds it to the global
grandTotal.
- Declares local variables
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 6. Kapitel 12
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
Fantastisk!
Completion rate forbedret til 1.25
Challenge: Scopes
Stryg for at vise menuen
Opgave
Swipe to start coding
You want to calculate total sales for a day using local and global variables.
- Declare a global variable
grandTotal(outside any method) to store the total sales. - Create a method
AddSalethat:- Declares local variables
priceandquantity. - Calculates the total for that sale and adds it to the global
grandTotal.
- Declares local variables
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 6. Kapitel 12
single