Question
Write a program that prompts the user (at the keyboard) for a value and searches the file uberstext for that value, printing out the last
Write a program that prompts the user (at the keyboard) for a value and searches the file uberstext for that value, printing out the last position where the number appears in the file (the first number in the file is at position 1). If the number does not appear in the file, print out an appropriate message. Continue asking the user for values until they signal end-of-file (in Windows one enters end-of-file at the keyboard by entering Ctl-Z, in Unix end-of-file is indicated by entering Ct-D). The logic is the same as end-of-file on a disk file-i.e, if your Scanner variable is named keyboard, you would have the loop condition while (keyboard.hasNextintO) The name of your class should be FiadLast.
For example, if the file beret contains.
10
23
43
5
12
23
9
8
10
1
16
9
Here is a sample execution of the program User input is in bold.
Your pogram should replicate the prompts and output
Enter a number: 10
10 last appears in the file at position 9
Enter a number: 29
29 does not appear in the file
Enter a number:9
9 last appears in the file at position 12
Enter a number
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started