Assignment 3 tokens solution


Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment


5/5 - (3 votes)

1) Reversing Tokens (10 marks) String Tokenization A common task in text processing is to parse a string by deleting the surrounding whitespace characters, keeping just the discrete words or “tokens” which remain. A token is a maximal substring which contains no whitespace characters. For instance consider the preceding sentence to be a string. The tokens in this string are listed as: (“A”, “token”, “is”, “a”, “maximal”, “substring”, “which”, “contains”, “no”, “whitespace”, “characters”). Whitespace here is defined to mean spaces, newlines, and tab characters.
Using what you know about tokens, make a program that accepts a file called “input.txt”, reads in all of the tokens in the file, and for each token reverses the token so that it prints the token backwards. The program should print these reversed tokens to a file called output.txt. Your program should be able to accept any arbitrarily sized files, (there should be no limit to the number of words it can reverse) You should submit just the java file itself, however your program should be able to accept and handle any input.txt file that is run against it.
Example input.txt: The Quick Brown Fox
output.txt ehT kciuQ nworB xoF

2) GUI using file input/output (15 marks) Thinking about the many different forms in your life, wouldn’t it be great if you could just automatically populate them with the information instantly? That’s the program we are going to write today. Write a program that has at least 5 labeled input fields which a user can enter information. (By default starting the program the fields should be blank). After the user has filled in the fields and clicked the save button, the program should save the output to a file and inform the user that their file has been successfully written. When the user clicks the load button, the FileChooser dialog should appear and the user should be able to select the input file the have previously generated in order to populate the fields. Your program should have 2 exception cases that it handles, if a user tries to save a file when they have not filled out all of the fields and if a user tries to load a file that does not have the expected input, (for example if the user selects an empty file) These exception cases should inform the user of these exceptions by changing the GUI in some way. Your program should look similar to the one below:
Please be creative when you create your at least 5 unique fields. Your program can be for any type of form, and you can choose to customize your program to make any form you like!