Yes -- the program will calculate the correct price in dollars. Study how the arithmetic is carried out. The value inside the parentheses is the cost in cents of each booklet. That value is multiplied by the number of copies, 25, to get the total cost in cents. The total cost in cents is divided by 100 to get the cost in dollars.
(7 * 3 + 5) * 25 / 100 = (21 + 5) * 25 / 100 = 26 * 25 / 100 = ----------- -------- ------- do first keep working do next 650 / 100 = 6.50 --------- finally
The first thing done is to work with the parentheses:
(7 * 3 + 5) * 25 / 100 = (21 + 5) * 25 / 100 ----------- -------- do first keep working
Inside the parentheses are two operators: * and +. Do the * first, because it has highest priority. Then keep working by doing the +:
(21 + 5) * 25 / 100 = 26 * 25 / 100 -------- keep working
When the insides of the ( ) is completed you are left with a number, 26. The rest of the work is done using the left to right rule:
26 * 25 / 100 = 650 / 100 = 6.5 ------- leftmost of two operators of equal priority
What does the following program print to the monitor?
' Parentheses first ' PRINT ( 2 * 3 + 2 ) / 4