Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions