Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Each row in our data files has exactly two tokens. The input.txt file has correctly formatted data. RestA 3 Beef 3500.00 Pork 1690.00 Chicken 2230.50

Each row in our data files has exactly two tokens. The input.txt file has correctly formatted data. RestA 3 Beef 3500.00 Pork 1690.00 Chicken 2230.50 RestB 1 Chicken 12537.50 RestC 2 Beef 2432.20 Pork 1690.00 The inputA.txt, inputB.txt, and inputC.txt files have wrong data on different lines. The inputA.txt file has an extraneous token on line 4. RestA 3 Beef 3500.00 Pork 1690.00 Chicken Leg 2230.50 RestB 1 Chicken 12537.50 RestC 2 Beef 2432.20 Pork 1690.00 The inputB.txt file has an extraneous token on line 8. RestA 3 Beef 3500.00 Pork 1690.00 Chicken 2230.50 RestB 1 Chicken 12537.50 RestC 2 Beef Stew 2432.20 Pork 1690.00 The inputC.txt file has an extraneous token on line 1. RestA Brampton 3 Beef 3500.00 Pork 1690.00 Chicken 2230.50 RestB 1 Chicken 12537.50 RestC 2 Beef 2432.20 Pork 1690.00 Warmup Activity 1 Compile and run the provided Lab5 class with the program argument input.txt. When running lab5s public static void main( ) method from BlueJ, you will be prompted with this familiar screen. Normally, you will just press the OK button. This time, you will provide the input data file name in double quotes. The program ran very fast in the small data file. The console will show the following message. You can also run the program from command prompt to get the same message on completion. But the input file name does not require enclosing double quotes on the command line. Whether you run the provided Lab5 program from command prompt or BlueJ, you will find the following output.txt file created in the same directory as the program. Warmup Activity 2 Run the provided Lab5 program again but this time with inputA.txt file. It has an extraneous word on line 4. After reading Chicken as the meat type, the program expects to find a dollar amount in double type. But it finds Leg instead. The result of running the program from a command prompt is shown. The bad data causes an exception. The result of running the program on BlueJ is similar. Lab Exercise You will create a class called Lab5A based on Lab5. Your new class will catch InputMismatchException and print the line number where the first erroneous data was found. Since the data format is wrong, the output.txt file will be incorrect and ignored. Users only care about fixing the input data with the help from the message. The output.txt file tells us which line to look for the error. Resources Your lecture slides should have enough information for you to complete both exercises. If you dont know how to start, Exceptions in Java - GeeksforGeeks may help. Submission Requirements 1. A word file with the screens of your program output running on all 4 data files provided. 2. Lab5A.java file.

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_2

Step: 3

blur-text-image_3

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

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

Assess three motivational theories as they apply to health care.

Answered: 1 week ago