← Back to If Statements
Question 211
If / Else with a Block of Statements
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 printsNo discount. After the whole statement, printFinal 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
Sign in to use hintsTopics:
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.