Question: Java This assignment will give you practice with line based file processing and scanner methods. Modify the Hours program we did in class. You are

Java

This assignment will give you practice with line based file processing and scanner methods.

Modify the Hours program we did in class. You are going to write a program that allows the user to search for a person by ID. Your program is required to exactly reproduce the format and behavior of the log of execution as follows:

 Enter an ID: 456 Brad worked 36.8 hours (7.36 hours/day) Do you want to search again? y Enter an ID: 293 ID #293 not found Do you want to search again? y Enter an ID: Kim ID is not valid Do you want to search again? nope  Have a nice day! 

At minimum, your program should have the following static methods in addition to method main: /* Your submission should have the exact same method headers as follows */

  • A method to find person information and return the line of data for the person. The method will return an empty string if the person data is not found in the file. The Scanner input is the connection to the file. You need to establish the connection before you call findPerson. Also you need to ask the user for the searchId number as well.
 public static String findPerson(Scanner input, int searchId) {
  • A method to calculate the total hours worked by the person and outputs their info. Here the line will be the person data extracted from the file matching the search id.
 public static void processLine(String line) {

When you ask the user whether or not to search again, you should use the next() method of the Scanner class to read a one-word answer from the user. You should continue playing if this answer begins with the letter y or the letter Y. Notice that the user is allowed to type words like yes. You are to look just at the first letter of the users response and see whether it begins with a y or n (either capitalized or not) to determine whether to play again.

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!