Question: 17. [after $3.23] Modify the PrintInitials program so that it takes input from the keyboard but prints output to a file named output.txt. Use these

17. [after $3.23] Modify the PrintInitials program so that it takes input from the keyboard but prints output to a file named output.txt. Use these suggestions: Add import java.io.PrintWriter; Append throws Exception to the main method header. Add this declaration: PrintWriter fileOut = newPrintWriter("outout.txt"); Substitute fileOut.println for System.out.println. Then add this final statement to the main method: fileOut.close(); * Printinit1als. Java * Dean \& Dean * This program prints the initials for a user-entered name. import java. ut11. Scanner: public class Printin1t1als C pub11c static void main(string[] args) . Scanner stdin - new Scanner(System. in): String first: 1/ first name String last: If last name System, out. print( "Enter your first and last name separated by a space: "): first - stdin.next( ) last - stdin. next(): System, out, printinc"Your initials are " + first. charAt (0)+ last. charAt (0)+"."; ; 3 If end main J I end class Printinitials Sample session: Enter f1rst and last name separated by a space: Ada Lovelace Your initials are AL
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
