#K43632. Evaluate Arithmetic Operations on an Integer Array
Evaluate Arithmetic Operations on an Integer Array
Evaluate Arithmetic Operations on an Integer Array
Given a list of integers and an arithmetic operator, you are required to evaluate the result by applying the operator sequentially from left to right. Formally, if the integer list is \(a_1, a_2, \dots, a_n\) and the operator is \(\otimes\), then you must compute the value of \(a_1 \otimes a_2 \otimes \dots \otimes a_n\). The operator can be one of the following: ADD, SUBTRACT, MULTIPLY, or DIVIDE (using integer division). Note that division by zero is not allowed. If the input list is empty or the operator is invalid, your program should report an error message.
inputFormat
The input is provided via standard input (stdin) in the following format:
- The first line is a string denoting the operator. It will be one of: ADD, SUBTRACT, MULTIPLY, or DIVIDE.
- The second line contains space-separated integers representing the list.
outputFormat
The output should be printed to standard output (stdout) as a single integer result after performing the sequential arithmetic operations. In case of an error (empty list, invalid operator, or division by zero), print the corresponding error message.
## sampleADD
10 3 2
15