Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Scopes | Methods
C# Basics

bookChallenge: 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 AddSale that:
    • Declares local variables price and quantity.
    • Calculates the total for that sale and adds it to the global grandTotal.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 6. ChapterΒ 9
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

close

bookChallenge: 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 AddSale that:
    • Declares local variables price and quantity.
    • Calculates the total for that sale and adds it to the global grandTotal.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 6. ChapterΒ 9
single

single

some-alt