[Solved] CPE211-Project #05

$25

File Name: CPE211-Project_#05.zip
File Size: 169.56 KB

SKU: [Solved] CPE211-Project #05 Category: Tag:
5/5 - (1 vote)

<Project 5 Description>

For this project, you will write a complete C++ program that performs all of the following tasks. Use variables of Data Type float to contain all numerical values.

  • Using command line arguments for an input file and output file name (see command line argument slides and page 3), 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. See page 4 for information on this test.
  • 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.
  • For steps 1 and 2 output a statement stating the name of the file being opened-see the solution
  • Read in the title line from the input file and write it to the output file.
  • Write the column headings to the output file (see the sample solution output)
  • For the first person, read in their first name, last name and four test scores. (check the project 5 input file information on page 3)
  • Find the average of the four test scores.
  • Write the information for the first person to the output file. Output the first 9 characters of the last name, the first 10 characters of the first name, the test average of the person and the letter grade for the test average (90,80,70,60 split for A, B, C, D and F) use an if-then-else-if statement to process the average
  • Repeat steps 6, 7 and 8 for the second and third person information in the input file no loops
  • Output of the program shall match that of the sample solution

<Project 5 Hints>

  • Make sure output is to the output file including the output statements that set up the formatting.
  • Use the ignore function (See page 3) to remove the new line character from the input stream (which is the input file specified) when a getline is used after an extraction operation.

  • The name columns are in a field width of 12 and left justified. The average column is output in a field width of 9, and the letter grade is just output (no setw used for it)
  • Print the comment line and the headers to the output file before processing the first person

  • One set of variables only are needed to hold the first name, last name, four test scores and average. Do all calculations and outputs for one person and then copy the code for use on the second and third persons. DO NOT USE LOOPS
  • Output the first 9 characters of the last name and the first 10 characters of the first name use the substring function

  • Run the sample solution (not the comparison script) to see what the program writes to the terminal and to the output file, and the order in which the information is written.
  • Look at the contents of an input file (see page 3) to see what has to be read. Note the use of commas to separate name parts.
  • Loops are not allowed on this project. Write the code necessary to process one student and then copy and paste it twice to process the next two students. Just remember to use ignore statements following extraction operations to remove the new line character.

<Project 5 Input File Format>

The Input file format is similar to the information shown below. Look at all of the provided input files to determine the exact format.

  • On all lines, a comma separates the last name from the first name and the scores from the last name. All scores are separated by spaces.
  • The first line of the input file is a header line which is to be copied to the output file

Note, use the getline function terminated on a comma to read in the first and last name of the person. Use the extraction operator to read the scores. Remember that first and last names can consist of multiple words.

<Project 5 ignore function>

Use the following format for the ignore function to ignore past the new line character in the input stream. INT_MAX is defined in the header file climits.

inputFileStream.ignore(INT_MAX,
);

<Project 5 Error Messages>

The program is to have error messages for the following conditions. Each of these tests results in termination of the program:

Two file open error message: one for the input file and one for the output file o 15 *s on each side of title, 47 across the bottom

Run the sample solution to see the various error messages. See page 4 for more details.

<Project 5 Command Line Arguments>

Be sure to look at the command line argument slides

For this program, instead of int main() use: int main(int argc, char *argv[ ])

To run your program, type the following at the command line:

./Project_05 input_file_name output_file_name

In your program, assign argv[1] to a string variable (i.e. inFileName=argv[1];) that is to hold the input file name and argv[2] to a string variable(i.e. outFileName = argv[2]) that is to hold the output file name. Use these string variables in the open function when opening the files.

When running the sample solution (not the comparison script), you must provide the input and output file names as command line arguments.

< Testing the State of the File Stream>

The following code is used to test the status of a file stream. Replace the file stream variable indicated (your_file_stream) with the actual name of the file stream used in your program. Also, replace the file name string variable (filename) with the actual name of the variable that holds the name of the file entered by the user.

if(your_file_stream.fail())

{ cout << string(15,*) << File Open Error

<< string(15,*) << endl;

cout << ==> Input file failed to open properly!!
; cout << ==> Attempted to open file: <<
filename << endl; cout << ==> Terminating program!!!
; cout << string(47,*) << endl;

return 1;

}

Output file open error message is the same as above just change the wording to reflect output versus input.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CPE211-Project #05
$25