Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Prob3 public static final String FILENAME advice.txt public static void main(String args) Scanner in - new Scanner (System.in) Scanner fin -nul1; try f

image text in transcribed
image text in transcribed
public class Prob3 public static final String FILENAME "advice.txt" public static void main(String args) Scanner in - new Scanner (System.in) Scanner fin -nul1; try f fin - nev Scanner (nev FileInputStream (FILENAME) System.out.println("Here's sone programing advice:n) while (fin.hasNextLineO) System.out.println(fin.nextLineO) fin.closeO; catch (FileNotFoundException e) // handle initial case when there's no advice file System.out.println("No advice to give yet.") PrintWriter fout -null; try f fout new PrintWriter(nev FileOutputStream (FILENAME)); catch (IOException e) System.out println(e) System.exit(-1); System.out.println("InPlease enter some advice for the next user. Hit tvice to en while (true) f String line in.nextLineO if (line, length() 0) // second leads to an espty line break; fout.println(line); System.out.println("Thanks for the advice!") fout.closeO

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

Genomes And Databases On The Internet A Practical Guide To Functions And Applications

Authors: Paul Rangel

1st Edition

189848631X, 978-1898486312

More Books

Students also viewed these Databases questions