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

  Describe the usefulness of the jframe class

What is a JFrame? Describe the usefulness of the JFrame class

  Take a position on whether or not an object-oriented

take a position on whether or not an object-oriented approach can be used to develop any type of system. provide two

  Strong authentication can also risk availability

Strong authentication can also risk availability. A simple example is that forgetting your password denies you access to that which required a password. Sometimes the stakes are high, for example, if a network administrator is the only one who knows ..

  Shows the users name and program name

Java program, the program has a page that shows the users name and program name. a second jpanel that shows 4 buttons (circle square rectangle and oval) the problem i am having is that my program is not dropping where i click and the shapes are not s..

  Write a java servlet to validate the data

Write a Java Servlet to validate the data submitted through the above registration page. If the required fields are empty relevant error messages should be displayed on the same registration page.

  Quadratic that solves quadratic equations

Write a method called quadratic that solves quadratic equations and prints their roots. Recall that a quadratic equation is a polynomial equation in terms of a variable x of the form ax2 + bx + c = 0. The formula for solving a quadratic equation is ?..

  Java enumeration lettergrade represent letter grades

Write a java enumeration LetterGrade that represents letter grades A through F, including plus and minus grades. Define a private instance variable holding a boolean value.

  Write a java program that demonstrates exception handling

For this project, you will write a Java program that demonstrates exception handling. Your program will accept from the user ten values and place those numbers in an array

  Convert string values from keyboard to numeric values

How do we convert string values from the keyboard to numeric values? How do we create output strings containing the values from our variables and how to answer the problem? Any help would be appreciated.

  Write a program that takes 10 values representin

Using a loop, write a program that takes 10 values representin exam grades (between 0 and 100) from the keyboard and outputs the minimum value, maximum value, and average value of all the values entered. Your program should not accept less than 0 ..

  Graphics program that draws 12 strings

Write a graphics program that draws 12 strings, one each for the 12 standard colors, besides Color.WHITE, each in its own color. Provide a class ColorNameViewer and a class ColorNameComponent.

  Write a portion of a program for a church website

Write a portion of a program for a church's website. The program will be used for a chatting feature, which should include an Input Box that requests the user's name.  The message box should include the user's name and the Scripture of the Day (ch..

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