Answered

ou are writing a program to analyze the financial data for a set of companies. Your coworker gives you a text file of company data. However, you are worried that your coworker didn't type the data in correctly. Write a program that will tell you if the data is correctly formatted. A file is formatted correctly if each opening parenthesis:
({
is closed out with it's respective "closing" parenthesis: ) \}]. The open bracket character ( matches ) on the same line, however, \{ and [ may match over multiple lines. Incorrect data could look like: [ company_name: (BlackRock( ticker: (BLK\{ stock_price: \{ 2022-04-03: (\$930] 2022-04-02:
($932}
\} Notes: - It doesn't matter if a field is surrounded by [], or \{\} - There will only be one or two parentheses on each line - Assume the only possible issue with the file is the parenthesis not matching Output: boolean - valid data format or not Test 1 Test Input [a company_name: (BlackRock) ticker: (BLK) stock_price: \{ 2022-04-03: (\$930) 2022-04-02: (\$932) 3 \}. \{ company_name: (Apple) ticker: (APPL) stock_price: \{ 2022-04-03: (\$175) 2022-04-02: (\$178) \} \} ] Test 2 Test Input [ [ \{ company name: (BlackRoek ( ticker: (BIR\{ stock price: \{ 2022-04-03: (\$930] 2022-04-02: (\$932\} 3 \} ] Expected Output [ aㅕ

Answer :

Other Questions