Challenge: Scopes
Task
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
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 6. ChapterΒ 9
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 1.67
Challenge: Scopes
Swipe to show menu
Task
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
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 6. ChapterΒ 9
single