Question: 1) a. Complete the Java program below so that it reads the text file dogNames.txt and writes its contents to another text file, doggoneData.txt. The
1) a. Complete the Java program below so that it reads the text file dogNames.txt and writes its contents to another text file, "doggoneData.txt". The file dogNames.txt contains just the single word "Tippy", so the output in "doggoneData.txt" should simply look like this: Tippy Your task is to complete the code below by using the variable name along with the appropriate Scanner and PrintWriter methods. String name; Scanner inputFile = new Scanner(new FileReader("dogNames.txt")); PrintWriter outputFile = new PrintWriter("doggoneData.txt");
b.
Complete the Java program below so that it reads the text file dogYears.txt and writes its contents to another text file "doggoneData.txt". Here the input file gives ages in dog years, and the output file reports these figures in human years (so Tippy is 2 in the input file, and 14 - 7 times older - in the output file.) The output in the file "doggoneData.txt", which gives dog ages in human years, should be formatted like this: Tippy 14 Rex 49 Desdemona 35 Your task is to complete the code below by using the appropriate Scanner and PrintWriter methods. String name1, name2, name3; int age1, age2, age3; Scanner inputFile = new Scanner(new FileReader("dogYears.txt")); PrintWriter outputFile = new PrintWriter("doggoneData.txt");
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
