Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ Program to: 1. Because command line arguments are used, first action of the program is to test to make sure that 2

Write a C++ Program to:

1. Because command line arguments are used, first action of the program is to test to make sure that 2 file names were provided. Use the test if (argc != 3). If the argc value is not 3, print out an error message and what the correct format should be for running the program and terminate the program.

2. Using command line arguments for an input file and output file name, open the input file provided as the first command line argument. Verify that the file opened successfully. If it did not open successfully, output an error message and terminate the program.

3. If the input file is successfully opened, open the output file provided as the second command line argument. Verify that the output file opened successfully. If it did not open successfully, output an error message and terminate. Use the filename Bad/file to cause the open function to fail for the output file.

4. For steps 1 and 2 output a statement stating the name of the file being opened-see the solution

5. The upper case letters A, B and C appear on the first, second and third line of the input file respectively. The input file contains a single occurrence of these letters. Immediately after each letter is a floating point number which must be read, and there may or may not be more characters after the numbers on each line

6. Read in the three numbers and then test to see if any of them are less than 0. If any are negative, determine which ones are negative, output a message as shown in the sample solution and terminate the program.

7. f all numbers are greater than or equal to 0, add them up and determine their average. From the average determine if the average is High (average >= 75), Medium (average < 75 and average >= 25) or Low (average < 25)

8. Write the numbers read, their sum, their average and the word High, Medium or Low based on the average to the output file run the sample solution to see the formatting necessary for the output. The row of *s is 47 *s long and the phrases are in a field width of 35.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

Draw a picture consisting parts of monocot leaf

Answered: 1 week ago