21 Aug Hey i have attached the required file for my
Hey i have attached the required file for my assignment.
and additionally i have also mentioned the points of assignments below.
this one is based on this concept.
Lab 4 (Collection Framework, Exception,
IO Handling, Generic method and GUI Programming)
NOTE: You should properly format your source code files for better readability and write appropriate comments in the code.
Exercise 1 [10 points]:
Write a program that asks a user for a file name and prints the number of characters, words (separated by whitespace), and lines in that file. Then, it prints the frequency of each word (case insensitive) containing in the file (Test1.txt); Your program should handle exceptions related to file opening and reading from the file.
This is a test this
Hi there hi hi hi
Output at the console:
Number of characters: 35
Number of words: 10
Number of lines: 2
Data written to the file (Test1.txt):
this 2
is 1
a 1
test 1
hi 4
there 1
Hint: you may use a HashMap to store and count the frequency of the words in the file.
Exercise 2 [20 points]:
Your task is to write a program that uses a textfile containing any number of lines of double values as input. Each line in the file is supposed to have no more than 15 values on it. If the file exists and each line in the file does in fact contain 15 or fewer double values, then the program processes and reports on each line in turn by displaying its line number, the number of values on that line, and the range of values on the line.
But, as you know, things are not always as they seem, or as they are supposed to be. For example, the file your program is looking for may not be there, there may be no double values at all on some lines, some lines may contain more values than the allowed maximum of 15, and some lines may contain “values” that aren’t even doubles (i.e., badly formatted “invalid” double values). The program must recognize and respond appropriately to each of these problems.
Note: You must implement exception handling. Not only am I requiring it, but Java itself will also require it since you will have to use Java resources that force you to deal with the IOException. In addition to this exception, you are also required to handle the ArrayIndexOutOfBounds and the NumberFormatException at appropriate points in your program.
This program reads in, from the command line, the name of a textfile containing any number of lines of doubles and then processes each line in turn. Processing a line means computing and then reporting, for that line, its line number, along with the range of values on the line.
The program can recognize a number of problems that may occur when trying to process such a file. First, the file itself may not be present. If so, the following message is displayed (the first line comes from the system, the second from the program itself):
filename.ext (The system cannot find the file specified) Program will now terminate.
If the file exists, and contains lines of double values, possibly with blank lines, possibly lines with too many values, and possibly lines with invalid doubles on them, then the following messages, each followed by a pause, are output, as appropriate:
Line #: Number of values = # and value range = [#, #].
Line #: This is a blank line.
Line #: This line contains more than the maximum of 15 allowed data values. Line #: This line contains an invalid double value.
For example, if a file name “text.txt” contains the following texts:
1.0 2.2 30.3
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Writedemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.