Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Operating System Expert

Write a simple text formatting program in Java, that will read words from an input file and write them to an output file, removing extra whitespace and filling each line with as many words as will fit up to a maximum column width (similar to a column of text in a newspaper). The maximum column width, input text file name, and output text file name are entered interactively when the program starts.

The program needs to perform the following activities:

* Prompt for the maximum formatted output width. The range is 30 to 100 characters.

* Prompt for the file name of the input text file. Test that the file exists, and can be read. If so, then only open the file for reading. Repeat these steps until a valid input file is entered.

* Prompt for the file name of the output file to write the formatted words to. Test that the file does not already exist, and if it does, prompt to check for overwriting the file. Repeat these steps until a valid output file is entered.

* Write a line of * characters, the width of the formatted output, as a heading in the output file (no formatted output line should be longer than this heading line), for example, if 45 was entered as the maximum output width, this line should have 45 * characters.

* Read words (text between whitespace) from the input file, appending them to a line of text being formatted, with one space character between words. Keep appending words until the current word would cause the line to become longer than the output column width. If so, write the line to the output file, reset it to contain just the new word, and continue reading. Continue reading until the end-of-file is encountered.

* Do not read the entire file into memory, and do not use an array to hold multiple lines in memory.

Attached are sample input-output, and two sets of test data that should be run with a width of 40 and width of 70.

Attachment:- Sample output.zip

Operating System, Computer Science

  • Category:- Operating System
  • Reference No.:- M91615490
  • Price:- $20

Priced at Now at $20, Verified Solution

Have any Question?


Related Questions in Operating System

Question topic computerized operating systems os are almost

Question: Topic: Computerized Operating Systems (OS) are almost everywhere. We encounter them when we use out laptop or desktop computer. We use them when we use our phone or tablet. Find articles that describes the diff ...

Assignment -building a multi-threaded web server using c

Assignment - Building a multi-threaded web server using C and p threads, following the model from the lecture. Your program will have one thread acting as a dispatcher thread, listening fornetwork connections with reques ...

Show all stepssuppose that the following processes arrive

Show all steps Suppose that the following processes arrive for execution at the times indicated. Each process will run the listed amount of time. in answering the questions, use non-preemptive scheduling and base all dec ...

State the required answer precisely and then provide proper

State the required answer precisely and then provide proper explanation. It is not enough to provide one- word or one-line answers. Briefly describe the following concepts and indicate how they are related in the context ...

Question 1answer the following questions 10 marks a

Question 1 Answer the following questions: 10 marks a. Consider the following page reference string: 3, 1, 4, 1, 2, 3, 5, 3, 2, 1, 2,5, 4, 3, 5, 2, 4,2, 5,3 Using the above page reference string display the contents of t ...

Question research hex editors available for mac os and

Question : Research hex editors available for Mac OS and Linux. Based on the documentation, how easy would validating these tools be? Select at least two hex editors for each OS, and discuss what you would do to validate ...

Question state the required answer precisely and then

Question : State the required answer precisely and then provide proper explanation. It is not enough to provide one- word or one-line answers. What is the purpose of the command interpreter? Why is it usually separate fr ...

Question note apa format 250 words and three reference

Question: Note: APA format 250 words and three reference without plagarism Computerized Operating Systems (OS) are almost everywhere. We encounter them when we use out laptop or desktop computer. We use them when we use ...

Catalog course descriptionin this course students carry out

Catalog Course Description In this course students carry out independent research in a significant technical area of information, network, and computer security. The student is to investigate a technical area, research i ...

Taskyour job in this assignment is to create two virtual

Task Your job in this assignment is to create two Virtual machines each running a different but the latest distribution of Linux e.g. Ubuntu Server and CentOS. Each of these VM's is to offer services to a user base. The ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As