Write a program that calculates how much a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day.
The program should prompt the user for an input file name and then read three pieces of information from that file. The files contents are: A person's first name, last name and an integer representing a number of days.
The program should then ask the user for an output file name. This filename will be used to open a file into which the program will write the output. Your program should write text into this file so that it contains a header with the name of the employee read and the number of days of salary to be displayed. Following this there should be a table showing how much the salary was for each day, and then show the total pay at the end of the period. The output should be displayed in a dollar amount, not the number of pennies.
Your program should test for successful opening of files and display an error message and then exit if the file fails to open. Any open files should be closed before the program exits. If your program works properly it should then display a message to the user informing them of the successful outcome as is shown in the example output.
An example of what the output might look like is below (user input is in red):
Give an input file name and an output filename: IN.TXT OUT.TXT
Program has ended, output is in OUT.TXT.
After the program runs, the output will be stored in the file OUT.TXT
Example files:
IN.TXT:
William Bruford 10
OUT.TXT (after execution):
Pay for William Bruford over the course of 10 days:
Day 1: $0.01
Day 2: $0.02
Day 3: $0.04
Day 4: $0.08
Day 5: $0.16
Day 6: $0.32
Day 7: $0.64
Day 8: $1.28
Day 9: $2.56
Day 10: $5.12