top of page

CPP Assignment Help: Recitation Assignment 3

Updated: Sep 26, 2021

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 file name.


This C++ Assignment post is designed to show the sample work of assignment help request by student to help. It's supposed to be the blog post to give overview of the C++ assignment help sample - if you're struggling in to start the CPP assignments and need solutions and expert guidance? check it out How we work .

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 file name. If no file name is provided, the program should print on a new line "No file 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 character by character until the end of file. 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, total number of characters (with spaces and newlines), number of digit characters (‘0’ - ‘9’), number of alphabetic characters, number of punctuation characters, number of words, and number of integers seen in the file.


A word is defined, similar to our definition in RA2, as a sequence of one or more non-whitespace characters separated by whitespace. An integer is defined as one or more digits. For example, 2345 is an integer, while 4.5 is not, but 4 and 5 are two separate integers.


In this assignment, we follow the (ctype.h) C/C++ header files definition for the function ispunct(c), which checks whether c is a punctuation character. Punctuation characters are all graphic characters (as in isgraph() function), that are not alphanumeric (as in isalnum() function), as defined in the original 127-character ASCII set.



Hints:

  1. Use functions such as: isdigit(), isalpha(), isspace(), isalnum(), ispunct().

  2. You can use get() method for reading from the input.

  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 5 test cases, these are case0-case4. Case0 is checking whether your program displays a message if there is no file name provided as an argument to your program. Note that case1 is for “myfile1” which is not included in the set. Your program will be checked against a file name, “myfile1”, that does not exist. Case2 is for an empty file, called “empty”. Case3 and case4 4 are for reading from the two files IntOnly and countAll, respectively, which they include data to be processed. Expected correct outputs are included in the files case0.correct-case4.correct.

  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_Fall2021/RA3. You can, for example, look at countAll by saying "cat $LIB/public/ RA_Fall2021/ countAll ", and you can look at the expected output by saying "cat $LIB/public/ RA_Fall2021/case4.correct".


Grading Table:

Testing Cases

Case 1: No file is found

Case 2: File cannot be opened

Case 3: Empty File

Case 4: Counting integers only

Case 5: Counting everything

Compiles Successfully


 

If you are looking for C++ assignment, coursework help Or struggling in to start the course and assignments. you can avail our service for assignment and book 1:1 session with expert to clear your doubts learn to write code by yourself. We offer help in college undergraduate level or any online course provided by top e-learning platform.


Want to know more how we work?


Or send your assignment help request to us through email, contact form or website live chat. our expert will review and let you know the price quote

bottom of page