Question: Complete the below function which takes as argument a filename WITHOUT the extension and reads the file filename.in line by line. Each line of this

Complete the below function which takes as argument a filename WITHOUT the extension and reads the file "filename.in" line by line. Each line of this file contains a mathematical operation. You must split the data in the line by space characters, perform the given operation and write the result to "filename.out" using standart mathematical notation. Assume that only the following four operations are available: ADD = Addition, SUB = Subtraction, MUL = Multiplication, POW = Power. If you detect an operation other than these you should write the message "Invalid Operation" to file. You can also assume that the input file always exists. You can also assume that all operands are integers. Example: === contents of "filename.in" === ADD 34 56 SUB 30 13 MUL 3 7 POW 2 5 CHK 3 4 === contents of "filename.out" === 34 + 56 = 90 30 - 13 = 17 3 * 7 = 21 2 ^ 5 = 32 Invalid Operation

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!