subject

First: write code that prompts the user for the name of a text file, opens that file if it exists and reads the file one line at a time printing each line to the screen. you must implement the file read in a try/catch block rather than throwing the exception on the main method. next: modify your code so that the program takes the name of two files from the command line, opens the first file if it exists for reading and the second file for writing and copies the text of the first file into the second file. as with the first step, you must implement this in a try/catch block with an appropriate error message in the catch block. next: complete the method reverse that takes a string and returns a new string that is the original string reversed. note that we did this method in the lab a few weeks ago, so if you have that code you can just paste it in here. next: modify your code so that instead of printing each line to the file, it prints the reverse of each line to the output file using your reverse method. finally: make a single change to your code so that instead of copying the file, it outputs the new file not just reversed, but with all characters transformed to uppercase letters. (hint: make use of string's touppercase() method for this).use the code skeleton below to start your code. create a new project and a new class named copyfile and paste the code skeleton into it. then look at the course notes on file i/o to fill in what you need in the skeleton./** * program to copy one file into another, using command line arguments * * @author your name here * @author your partner name here * @version date here * */import java. io. filenotfoundexception; public class copyfile { /** * returns the reverse of the input string instring. * * @param instring * the string to be reversed * @return the reverse of instring */ public static string reverse(string instring) { // todo - complete this function // todo - the following line is only here to allow this program to // compile. replace it and remove this comment when you complete // this method. return ""; } public static void main(string[] args) { //todo: prompt the user for a filename //todo: open the file and print each line to the screen. //todo: don't forget to close the file when you are done. try { } catch (filenotfoundexception e) { } }}to test this program you will need a text file to read. create a new text file in eclipse by going to new -> untitled text file. then paste in the following text: jabberwocky'twas brillig, and the slithy tovesdid gyre and gimble in the wabe; all mimsy were the borogoves, and the mome raths outgrabe."beware the jabberwock, my son! the jaws that bite, the claws that catch! beware the jubjub bird, and shunthe frumious bandersnatch! "he took his vorpal sword in hand: long time the manxome foe he soughtso rested he by the tumtum tree, and stood awhile in thought. and as in uffish thought he stood, the jabberwock, with eyes of flame, came whiffling through the tulgey wood, and burbled as it came! one, two! one, two! and through and throughthe vorpal blade went snicker-snack! he left it dead, and with its headhe went galumphing back."and hast thou slain the jabberwock? come to my arms, my beamish boy! o frabjous day! callooh! callay! "he chortled in his joy.'twas brillig, and the slithy tovesdid gyre and gimble in the wabe; all mimsy were the borogoves, and the mome raths outgrabe. -- from through the looking-glass, and what alice found there (1872).save this in the top-level of your project folder for this lab and name it "jabberwocky. txt". note that it should be in your project folder and not in the src folder inside the project folder. when you run your program enter that file name as your input file - if your code is correct it will display the whole file to the screen. once you have done that, modify your code so that it prompts for two filenames and makes a copy from your input file to your output file.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 17:00
Which of the following is not contained on the slide show toolbar? a. next button b. slide button c. close button d. pen too
Answers: 2
question
Computers and Technology, 24.06.2019 16:50
Develop the program incrementally: a) start by reading and displaying each line of the input file to make sure you are reading the data set correctly. b) use the split string method to extract information from each line into a list. print the list to prove that this step is working correctly. d) convert the exam scores to type int and calculate the student’s average. display those items to prove this step is working correctly. e) create a tuple containing the six items for each student (name, exam scores, exam mean). display the tuples to prove this step is working correctly. (optionally, you may want to have the exam scores in a list so your tuple is (name, scores_list, f) append each tuple to a list. display the list to prove this step is working correctly. g) use the sort list method to re-order the tuples in the list. display the list to prove this step is working correctly. h) use a for statement to display the contents of the list as a table (with appropriate formatting). i) use a for statement to calculate the average of all scores on exam #1, then display the results. note that you could have calculated this average within the first loop, but we are explicitly requiring you to do this calculation by looping though your list of tuples. j) add the logic to calculate the average of all scores on exam #2, then display the results.
Answers: 2
question
Computers and Technology, 25.06.2019 08:20
The control unit takes ths instructions fetched by the preteched unit and translates them into a form that can be understood by
Answers: 1
question
Computers and Technology, 25.06.2019 18:00
Peter wants to query to determine the names of the students who scored more than 95 in the internal assessment test which function should he use in the query
Answers: 1
You know the right answer?
First: write code that prompts the user for the name of a text file, opens that file if it exists a...
Questions
question
English, 10.03.2020 18:03
question
History, 10.03.2020 18:03
Questions on the website: 13722367