Each student shall generate a single Python source file named balanced.py. This Python script shall open the Java source file specified in the command line argument provided at run-time, strip it of comments and save the comment-free version in a new file. The Python program shall then verify the Java source file meets the rudimentary syntax requirements for balanced parentheses, brackets, and braces. That is, every opening punctuation requires matching closing punctuation. A left curly-bracket requires a right curly-bracket for balance.

Respuesta :

Answer:

Hi Castiel! One way to implement this program is by using regular expressions combined with file operations in Python. Please find the answer explanation below:

Explanation:

First, we define the variables for the input and output files. Then, we can declare separate arrays for each kind of parenthesis (braces, curly brackets, parenthesis) so that we can count the total number of opening parenthesis and tally with the count of the total number of closing parenthesis.  Please refer to the attachment "balanced.py".

ACCESS MORE
ACCESS MORE
ACCESS MORE
ACCESS MORE