Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

hours file

123 Kim 12.5 8.1 7.6 3.2 456 Brad 4 11.6 6.5 2.7 12 789 Stef 8 7.5 012 Nancy 3 9 2.5 4.5 1.5 1 345 Kevin 40 678 Dayne 1.5 2.0 3.5 4.5 5.0 901 Iva 9 8.5 7 6.5 5 4.5 234 Jordan 0 0 0 1 0 0 0 567 Gabe 5.0 3.0 2.5 890 Lisa 12.5 16.5

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

More Books

Students also viewed these Databases questions

Question

Find y'. y= |x + X (x) (x) X 1 02x+ 2x 1 O 2x + 1/3 Ex 2x +

Answered: 1 week ago