Question: Intro to java The following program and file are for questions 13-16 Here is the file input.txt Persiko, Craig Griffin, Don Newsom, Gavin Schwarzenegger, Arnold
The following program and file are for questions 13-16 Here is the file "input.txt" Persiko, Craig Griffin, Don Newsom, Gavin Schwarzenegger, Arnold Here is the program (Name.java): import java.util.Scanner: import java.io.* class Name public static void main (String1 args) throws 1OException Scanner inFile - new Scanner (new File("input.txt) PrintWriter outFile new PrintWriter(new File ("output.txt) String lineIn, first, last: int strIdx: while (inFile.hasNext )) lineIn inFile.nextLine): stridx- lineIn.indexof( first lineIn. substring (strldx+1) last 1ineIn.substring (0, strIdx): System.out.printin(last): outFile.println (first+last): replace this line for question 16 inFile.close ) outFile.close); 13. What will the above program output on the screen? A. Craig D. last last last last last last B. Persiko C. Craig Persiko Griffin Newsom Schwarzenegger Obama Don Griffin Gavin Newsom Arnold Schwarzenegger Arnold Barack Ban Ki-moon E. Nothing would be displayed 14. What will the above program output to the file 'output.txt"? A Craig B. Persiko C. Craig Persiko Griffin Newsom Schwarzenegger Obana Ki-moon Don Griffin Gavin Newsom Arnold Schwarzenegger Barack Obama Ban Ki-noon D. first last first 1ast first last Gavin Arnold first last E. Nothing would be saved in the file
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
