Respuesta :
The calculator program is an illustration of iteration (loop) and conditional statements
What are iterations?
Iterations are program statements that are used to perform repetition operations
What are conditional statements?
Conditional statements are statements used to make decisions
The main programs
The program written in Python, where comments are used to explain each action is as follows:
#This initializes the subtotal and total to 0
subTotal = 0; total = 0
#This initializes the previous number to an empty list
prevNum = []
#This iteration is repeated for valid inputs
while True:
#This gets the input from the user
num = int(input())
#This calculates the subtotal
subTotal+=num
#This calculates the total
total+=num
#If the current input is 0
if num == 0:
#This prints the sub total
print("Subtotal:",subTotal)
#This sets the sub total to 0
subTotal = 0
#If the previous number is empty
if len(prevNum) == 0:
#This sets it to the current input
prevNum.append(num)
#If otherwise
else:
#If the previous number and the current input are 0
if(prevNum[0] == 0 and num == 0):
#This prints the total input
print("Total:",total)
#This exits the loop
break
#If otherwise
else:
#This sets the previous number to the current input
prevNum[0] = num
Read more about similar programs at:
https://brainly.com/question/26497128