Take your payroll program further — instead of printing the report, write it to a file | Workbook p.23
Continue the payroll-calculator program you wrote earlier. Before, you read employee records from a file and printed the payroll report to the screen. Now you're going to save that report to a new file instead.
Ask the user two questions: the name of the input file (the employee file you already know how to read) and the name of the output file (where the payroll report should be written). Each line in the output file should follow this format: id|name|gross pay — for example 111|Cameron Tay|3277.65. When the program finishes, the user should be able to open the file they named and see the full report.
Bonus: If the user types a file name ending in .json, write a JSON array instead of pipe-delimited lines. Each employee becomes a JSON object like {"id":111,"name":"Cameron Tay","grossPay":3277.65}, and all objects together form one array.
Workbook 3a, p.23 — Exercise: Payroll Calculator (Write)