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.
Attached are sample input-output, and two sets of test data that should be run with a width of 40 and width of 70.© BrainMass Inc. brainmass.com October 17, 2018, 3:14 am ad1c9bdddf
This posting contains the solution to the given problems.
Java Programming: Payroll Program Example
1. Modify the Payroll Program so that it uses a class to store and retrieve the employee's name, the hourly rate, and the number of hours worked.
2. Use a constructor to initialize the employee information, and a method within that class to calculate the weekly pay. Once stop is entered as the employee name, the application should terminate. Make sure the program maintains all the functionality required in previous assignments and your source code is readable and well documented.
For right now, you just need to create a single instance of the class file and use the getters/setters to set and get the information.
I have attached the first part of this Payroll Project, just need to add the above to this program.View Full Posting Details