Challenge: Scopes
Oppgave
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
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 6. Kapittel 12
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Fantastisk!
Completion rate forbedret til 1.25
Challenge: Scopes
Sveip for å vise menyen
Oppgave
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
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 6. Kapittel 12
single