calculator: fixed digit input format, print output only when arithmetic operation is successful