Create a file called pp6ainput.dat and type one integer in it, 55. Compile and execute pp6a.cpp. Check
Fantastic news! We've Found the answer you've been seeking!
Question:
Create a file called pp6ainput.dat and type one integer in it, 55. Compile and execute pp6a.cpp. Check to see if you now have a file called pp6aoutput.dat that has the words "The number is: 55". Add code to pp6a.cpp to do the following:
- Read multiple integers from input.dat and write them to output.dat until the end of the input.dat file. Edit input.dat and put several integers in it. Execute this program and take a screen shot of output.dat.
- Ask the user for the name of the input file and check to see if it exists. If it does not, print the error message "File xxxx does not exist" where xxxx is the name of the file. If it does exist, ask the user for the name of the output file, read numbers from the input file and write them to the output file until the end of the input file. Do not ask the user for the name of the output file if the input file does not exist. Follow the test instructions and take a screen shot of this code executing.
- Check to make sure the input file isn't empty. If it is empty, print the error message "File xxxx is empty." where xxxx is the name of the file. If it is non-empty, ask the user for the name of the output file, read numbers from the input file and write them to the output file until the end of the input file. Do not ask the user for the name of the output file if the input file is empty. Follow the test instructions and take a screen shot of this code executing.
- Write the output as dollar amounts by writing two small functions. The first reads the number from the input file. It has two parameters, the ifstream and the number. The post-condition is that the actual parameters are changed. The second writes the number to the output file formatted as a dollar amount, such as $123.45, with a $ and exactly 2 digits to the right of the decimal. It also has two parameters, an ofstream, whose actual parameter is changed in the course of writing, and the number to be written. Follow the test instructions and take a screen shot of the code executing AND of the contents of output.dat after the program executes.
Remove pp6aoutput.dat
Enter the name of a file that doesn't exist - blah.dat
Verify pp6aoutput.dat still doesn't exist after program execution. In this test, all output prints to standard output
This is the part I cannot get to work
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date: