Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: Scopes | Metodit
C# Perusteet

bookChallenge: Scopes

Tehtävä

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.

Ratkaisu

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 6. Luku 12
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

close

bookChallenge: Scopes

Pyyhkäise näyttääksesi valikon

Tehtävä

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.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 6. Luku 12
single

single

some-alt