Additional points: 1. Vocareum requires a perfect match of whitespaces, including newlines. Please check the sample output in the assignment carefully to see whether, for example, an input is being...

1 answer below »

Additional points:


1. Vocareum requires a perfect match of whitespaces, including newlines. Please check the sample output in the assignment carefully to see whether, for example, an input is being accepted on the line after the input prompt is displayed. If so, please place a newline accordingly.


2. The assignments often require a newline to be placed after the output has been fully displayed. Open the .correct file and see if it contains a blank line at the end. If so, add a newline after displaying the output.


3. After entering an input, Vocareum enters a newline. This input and the newline after it is not present in the .correct file. If there are additional newlines in the .correct file after accepting the input, these newlines must be generated by your program. Use cout to place them in the correct position after you accept the input.




CS 280 Spring 2022 Recitation Assignment 3 February 3rd, 2022 Due Date: Sunday, February 7, 2022, 23:59 Total Points: 8 Write a C++ program that accepts one command line argument for a file name, and ignores any extra command line arguments that may be provided after the first one. If no file name is provided, the program should print on a new line "No file name is found", and exit. If the file cannot be opened, print on a new line "File cannot be opened: ", followed by the file name, and exit. The program should read from the file lines until the end of file is found. If the input file is empty, print out the message "File is empty." on a new line and then exit. The program should count the number of lines, the number of non-blank lines, the total number of words, the number of names, and the number of integers, seen in the file. A word is defined as a sequence of one or more non-whitespace characters separated by whitespace. A word is defined as a name if it starts by a letter and followed by zero or more letters, digits, underscores ‘_’, ‘@’, or ‘.’ characters. For example, value, val@l9, num234ten, num_45 are valid names, but 9val, and _num are not. A word is defined as an integer if it starts by a digit and followed by zero or more digits (ignoring signed integers). For example, 2345 is an integer word, while 44.75 and 4today45 are not. Note that a line having only whitespace characters is a non-blank line as well. For example, given an input file of the following contents: Line number File contents 1 3456 Georgre@ 10-25, 125 2 1234 smith- boss 4_5 g_45 3 4321 staci_ class 12.75 -zy 4 278 sandra 25.35 $$ + x2 7y scr.squ njit. End of File ◼ Notice the difference between the newline marker on Windows and Linus. • On Windows it is the combination of carriage return (ASCII 0x0d or \r) and a newline(\n), also referred to as CR/LF. • On Linux it is just a newline (\n) The displayed output would be as shown below: Hints: 1. Use functions such as: isdigit(), isalpha(), isspace(), isalnum() to check for digit characters, alphabetic characters, whitespace, or alphanumeric characters, respectively. 2. You can use getline() method for reading from the input file. 3. Download the zipped file for the test cases from Canvas. These are the test cases you will be graded against on your submission to Vocareum. Use the test cases to test your implementation. 4. There are 7 test cases, these are case1-case7. Case1 is checking whether your program displays a message if there is no file name provided as an argument to your program. Note that case2 is for “myfile” which does not exist. See the grading table below for descriptions of case3 to case7 5. If you want to look at the input for one of the test cases, use the linux "cat" command. The cases are in the directory $LIB/public/RA_Spring2022/RA3. For example, you can look at “case3” file by using the command "cat $LIB/public/ RA_Spring2022/case3", and you can look at the expected output for this case by saying "cat $LIB/public/ RA_ Spring2022/case3.correct". Submission Guidelines 1. Please name your file as “RAx_firstinitial_lastname.cpp”. Where, “firstinitial” and “lastname” refer to your first name initial letter and last name, respectively, and “x” refers to the recitation assignment number (e.g., 1, 2, etc). Your program Submission is to Vocareum environment. Follow the link of Recitation Assignment 2 on Canvas in the Modules or Assignments pages to connect to the current assignment on Vocareum. 2. Submissions after the due date are accepted with a fixed penalty of 25%. No submission is accepted after Tuesday 11:59 pm, February 9, 2022. Total Number of Lines: 5 Number of non-blank lines: 4 Number of Words: 23 Number of Integers: 5 Number of Names: 9 Grading Table: Testing Cases Points Case 1: No file name is found 1.0 Case 2: File cannot be opened 1.0 Case 3: Empty File 1.0 Case 4: All Whitespace 1.0 Case 5: Words with integers 1.0 Case 6: Words with names 1.0 Case 7: Words with names & integers 1.0 Compiles Successfully 1.0 Total 8
Answered 3 days AfterFeb 03, 2022

Answer To: Additional points: 1. Vocareum requires a perfect match of whitespaces, including newlines. Please...

Aditya answered on Feb 07 2022
118 Votes
3456 Georgre@ 10-25, 125
1234 smith- boss 4_5 g_45
4321 staci_ class 12.75 -zy
278 sandra 25.35 $
$ + x2 7y scr.squ njit.
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here