CJCoding With Joseph
15free / daySign inCreate account

If / Else with a Block of Statements

The variable price starts at 120. Orders over 100 get a 20 dollar discount. Write an if / else where the if block contains two statements: first store 20 in the variable discount, then subtract discount from price. The else block prints No discount. After the whole statement, print Final price:  followed by price. Braces let a branch hold as many statements as you need.

Expected Output:

Final price: 100

= newline. The output ends with a newline — print one after the last line.

Hints3 available
Topics:
If Statements
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (clog, fn, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.