Question: Run Remember.main() Or subsequently by selecting Remember from the dropdown list in the top right corner of the IDE and clicking the green arrow. Here
Run Remember.main()
Or subsequently by selecting Remember from the dropdown list in the top right corner of the IDE and clicking the green arrow.
Here is an example session showing what should happen the first time someone runs the program (user input in bold):
No one has run this program before! What is your name? Alice Ok, Alice, I'm writing your name to a file
An example session showing what happens the second time someone runs the program (user input in bold):
The last person to run the program was Alice What is your name? Bob Ok, Bob, I'm writing your name to a file
The next time someone runs the program, it will print Bobs name as the last person to run the program.
Hints
Store the name of the last person to run the program in a text file.
You can use a FileReader and BufferedReader to read from the file, and a FileWriter to create the file.
You will need to be able to determine whether or not the file containing the name has been created. You can do so as follows. The variable fileName is a String which is provided that contains the filename (and path) in which the name should be stored:
File f = new File(fileName); if (f.exists()) { // the file exists } else { // the file has not been created yet } Once the file is created, it should appear in the CS201_Lab05_Gradle directory.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
