Question: Programming Assignment AT-File WritelRead- While-Loop Write a main program FileDemo that will Part 1 Enter values on keyboard and write them to a file (DO

 Programming Assignment AT-File WritelRead- While-Loop Write a main program FileDemo that
will Part 1 Enter values on keyboard and write them to a

Programming Assignment AT-File WritelRead- While-Loop Write a main program FileDemo that will Part 1 Enter values on keyboard and write them to a file (DO NOT ADD THEM HERE): First, Prompt the user for a filename to save the numbers entered from keyboard. Print prompt: "Enter file name Second, read the input from the keyboard and save in a filename variable. Remember how to do that? Third, Using PrintWriter, create the file provided on the input, to write a new file (or overwrite it) Then, In a loop (what type of loop will you use?), Prompt user to enter a number until -1 is entered. The Sentinal value is -1 Print prompt: "Enter a number from 1 to 100, 1 to quit" Inside the loop, Malidate the input by checking if number is in the range of 1 to 100 (inclusive). If the number IS valid, then write that number to the opened file. If the number is not valid (1-100), DO NOT write the number to the file: Display "Invalid Input Number must be from 1-100" Prompt user to "Enter a number from 1 to 100, 1 to quit. Once "-1" is entered (the sentinel value), Do not write -1 to file, but close the file and print to Console: "Data written to the file

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!