...

Variables in Action

We just learned that the right-hand side of an assignment statement can be an expression. Let's build upon this knowledge with a more complex example.

The code sample in this exercise applies an 8% tax on any given price, and prints out the result. However, the first line is incomplete.

Complete the first line by creating a variable called price, and assigning it a number. Then run the code sample to see how the different calculations are stored in variables, and how values stored in variables are recalled in various places in code.

Loading...

Output (Console)