What wc produces on a linux system

Assignment Help JAVA Programming
Reference no: EM13848780

Overview: The UNIX operating system (and its variants, of which Linux is one) includes quite a few useful utility programs. One of those is wc, which is short for Word Count. The purpose of wc is to give users an easy way to determine the size of a text file in terms of the number of lines, words, and bytes it contains. (It can do a bit more, but that's all of the functionality that we are concerned with for this assignment.) Counting lines is done by looking for "end of line" characters (\n (ASCII 10) for UNIX text files, or the pair \r\n (ASCII 13 and 10) for Windows/DOS text files). Counting words is also straight-forward: Any sequence of characters not interrupted by "whitespace" (spaces, tabs, end-of-line characters) is a word. Of course, whitespace characters are characters, and need to be counted as such.

A problem with wc is that it generates a very minimal output format. Here's an example of what wc produces on a Linux system when asked to count the content of a pair of files; we can do better!

$wc  prog3a.dat  prog3b.dat
2 6 38 prog3a.dat
32 321 1883 prog3b.dat
34 327 1921 total

Assignment: Write a Java program (completely documented according to the class documentation guidelines, of course) named Prog3.java that counts lines, words, and bytes (characters) of text files. The output format is shown in the Output section, below.

The user is to be able to supply the name(s) of the file(s) in two ways. The first is on the command line, as wc expects. We saw how to read command-line arguments recently, and there's an example program that demonstrates how to do it (T01n24). If there are no command-line arguments, your program is to display some usage information and prompt the user to enter the file name(s) on the keyboard.

Data: On the class web page you can find the two files, prog3a.dat and prog3b.dat, that I used to create the example above. These are just sample input files, meant to get you thinking about how wc behaves. You should plan to create several sample input files of your own to test further the behavior of your program. You can be sure that your section leader will be grading your program by testing it on a variety of files. The more testing you do, the greater the likelihood that your program will work correctly when graded.

Output: Your program is to produce counts of the number of lines, words, and characters (bytes) found in each readable file provided on the command line, and the output is to be displayed to the user in the well-structured, clearly-labeled format shown below, starting with a blank line. The five lines above the table (a blank line, the description, another blank, and the prompting line) are to be displayed only when no filenames are given on the command line. Here is an example of the output we expect when the user gives no file names on the command line but provides two when prompted:

This program determines the quantity of lines, words, and bytes in a file or files that you specify.

Please enter one or more file names, comma-separated: prog3a.dat, prog3b.dat

Lines Words Bytes
-------- -------- --------
2 6 38 prog3a.dat
32 321 1883 prog3b.dat
-----------------------------------------
34 327 1921 Totals

If the user supplies the name of only one existing, readable file, the last two lines (the line of hyphens and the line of totals) are not to be displayed. If, when prompted for file names, the user fails to give any usable file names, your program is to terminate after displaying some helpful instructions about what the program does, what input is expected from the user, and what output the user can expect to receive. As shown, we expect the list of file names to be comma-separated when received from the direct prompting (no commas are typed when names are given on the command line, in keeping with common UNIX command line behavior).


Attachment:- Assignment.rar

Reference no: EM13848780

Questions Cloud

Racism is primarily a belief or attitude : Some people argue that racism is primarily a belief or attitude and that anyone who unfairly judges another based on race is racist. Others argue that racism is about action and systemic discrimination, so only those with the power to act, and not th..
Research study on medical tourism : RESEARCH STUDY ON MEDICAL TOURISM, What are the types of medical procedures that tourists usually seek in India?
Access and complete the expository essay : Access and complete the "Expository Essay: Pre-Writing Worksheet." This worksheet will walk you through the writing process steps of choosing a topic, writing a thesis, prewriting (or Invention) techniques and reflection.
Write a descriptive essay on dubai city : Write a two-page descriptive essay on one of the following topics (choose just one). Underline your thesis statement.
What wc produces on a linux system : Write a Java program (completely documented according to the class documentation guidelines, of course) named Prog3.java that counts lines, words, and bytes (characters) of text files.
Most important aspect of writing a paper : It is imperative that you CITE. This is the most important aspect of writing a paper. If you paraphrase from a book or journal article, you need to give me the citation from where you found the idea
Biotechnology questions : Biotechnology Questions, Virus-mediated transfer of cellular genetic material from one bacterial cell to another by means of virus particles is called:
Calculates payment necessary to accumulate a future amount : Calculates the payment necessary to accumulate a future amount
Detail the characteristics the lead : Projects in the News REFLECT on the APA Exposed Tutorial in the Lecture Folder for this week. Review any newspaper article, periodical, or journal - printed oronlinethat has been published within the last three (3) months that is project-related.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Design your own three-stage explicit runge-kutta method

Design your own three-stage explicit Runge-Kutta method with one-step error O(h^4) - Confirm that the global error in your numerical solution is O(h^3).

  Write a java class

Write a Java class called PQueue that extends the provided abstract QueueADT class.

  Write a class called palatine

Write a class called palatine that converts an STL string into Pig Latin form. The rules for converting a string into Pig Latin are as follows.

  Explain where the following method invocations

Explain where the following method invocations are most likely to be found in a program for dealing with census data organized using the Model, View, Controller (MVC) design pattern. Choices are zero or more of Model, View, and Controller. Be sure to..

  Write a program that reads in the file

Write a program that reads in the file and exports it to a standard CSV format. For the records above, the output format would be Freddy Kruger, 1313 Mockingbird Lane, Houston, Texas Billy Thornton, 1010 Slingblade Street, Houston, Texas

  Create a class named employee and its subclasses

Create a class named Employee and its 3 subclasses named Contractor, HourlyEmployee, FullTimeEmployee. The class Employee hold first name and last name information, and defines two methods, respectively computing pay and vacation hours, that needs..

  Calculate the area and circumference of a circle

Write a program to move and calculate the area and circumference of a circle. - Calculate function, which passes the radius by value, and get back the area (PI*radius*radius) and circumference (2*PI*radius) of the circle through reference

  Program 2 classes one called student one called grades

program 2 classes one called student one called grades functional requirements ask for how many students u need to

  Determine the length of a string

Determine the length of a string. The first version should use array subscripting, and the second version should use pointer arithmetic

  Illustrate how to create a bufferedinputstream

What are Buffered Input / Output Streams and why are they used - write some Java code to illustrate how to create a BufferedInputStream.

  Write a java test program

Write a Java test program, all the code should be in a single main method that calculates and outputs the average of the numbers 1, 2, 9, 27, and 54.

  Why do regulators mandate the use of spread spectrum

Why do regulators mandate the use of spread spectrum and what are some spread spectrum transmission options?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd