Question: Write a program that analyzes a text file and performs simple math operations, for each line of the file. The program should catch exceptions when

Write a program that analyzes a text file and performs simple math operations, for each line of
the file. The program should catch exceptions when the action cannot be executed, it should display
an appropriate message, and move to the next line.
Operations are limited to addition/subtraction, division/multiplication (up to two operations),
and a single parenthesis. Define your own exceptions, including the following exemplary situations:
1+(2*3=
syntax error: ')' expected
1+(2*3)
5+12/0=
5+a=
5/1000000000000000000000=
c^{g~[\pm Z
syntax error: = expected
Zero Division Error
runtime error: a undefined
integer limit (>32-bit required)
illegal characters
If the text file is missing/cannot be opened, the program should display an appropriate message.

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!