Program description

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.

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
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.