Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.
Input Expected Output

Using an editor like nano, type the following numbers in a file called pp6ainput.dat. This is not a C++ file.

1 77

-1

100

Then, execute the program. The Expected Output should be in pp6aoutput.dat, not written to standard output (the display).

The number is 1

The number is 77

The number is -1

The number is 100

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.

Enter input file name: blah.dat

File blah.dat does not exist

Create an empty file called empty.dat with the following command:

touch empty.dat

Enter empty.dat for the input file name

The program should not create an output file so make sure pp6aoutput.dat does not exist. In this test, all output prints to standard output.

Enter input file name: empty.dat

File empty.dat is empty

Type the following integers in the file pp6ainput.dat

1 77.77

-1

100.99

Enter input file name pp6ainput.dat

Enter output file name pp6aoutput.dat

The outputs starting with "The number is ... " should be in output.dat. These should not be written to standard output (the display). The prompts for the file names print to standard output.

Enter input file name: pp6ainput.dat

Enter output file name: pp6aoutput.dat

The number is $1.00

The number is $77.77

The number is $-1.00

The number is $100.99

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

who is protected by NBFIRA and Insurance Prudential rules

Answered: 1 week ago