In Java Please /* Write a method called firstWord that takes String parameter ca
ID: 3767475 • Letter: I
Question
In Java Please
/*
Write a method called firstWord that takes String parameter called input, with no return value,
and is declared to throw an Exception. In the method, check whether the first char of the
parameter is a letter. If its not a letter, throw an exception that prints "Error".
Write a method called secondWord that takes no parameters and returns a String.
Prompt the user for input, and then call the firstWord method,passing as a parameter the word the user provided as input.
The secondWord method needs to handle the Exception that might be thrown by firstWord.
Write a method called sampleFi that takes two parameters: an array of Strings (arrayFi), and a String (fileN).
The method writes the Strings in the arrayFi array to a .txt file called fileN (the parameter), with each String on a separate line.
Write a method called readF that takes a String as a parameter (fileN)
and returns an ArrayList of Strings (Content). The method reads the text file identified by the fileN parameter
and populates the ArrayList with an element for each line in the text file.
In main method
Call secondWord and print results to command line.
Create an array of Strings called sampleElements and populate it with at least three elements.
Call the sampleFi method and pass the sampleElements array and the string "elements.txt".
Call the readF method to read the file elements.txt
Assign the result of readF to an ArrayList variable in main called Content.
Write a loop to print the contents of the Content ArrayList to the command line.
*/
Explanation / Answer
Program:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.