Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need help with this java coding assignment. Please explain the code once you have completed it. I really want to learn how to go about
Need help with this java coding assignment. Please explain the code once you have completed it. I really want to learn how to go about doing this. Thank you very much for your help!
TASK You are working for a farm corporation that serves as a major supplier of lettuce to the US and international markets. The corporation owns a large number of fields spread across a large number of farm locations in the lettuce-growing region. You are helping to build a system tracking the origin of lettuce back to the field where it was grown across the many farm locations and fields where the corporation grows lettuce. This system will not only help with planning and forecasting, but will also allow for tracking food-borne illness for public health purposes. Your task involves transforming data about each head of lettuce into an intermediary code that is later sent into a bar code generator, to be included on the packaging. The inputs to your program will eventually be supplied by other systems, but for testing purposes you will let the user enter the data from the keyboard. There are three input strings. These strings come in formats produced by other systems; these formats cannot be changed. The input strings and their formats are as follows: - The variety of lettuce. This could be any word or sequence of words. Variety names are guaranteed to be at least 4 letters long. Variety examples are: "romaine", "RUBY Loose Leaf", "Cimmaron", "BIBB", "Tom Thumb", etc. - The location ID within the corporation. This ID consists of a number that represents the farm ID, followed by the word "id" in any case, followed by a number that represents the field ID. For example, "54id4", "9083ID451", "8Id30" are three examples of location IDs. - The harvest date of the lettuce. This comes in a format of day/month, where day is a number between 0 and 31 and month is a full name of the month in any capitalization (February, July, etc.) Examples of production dates are: "1/February", "15/MARCH", "31/december". The two parts of the date string are separated by a '/' character. There are no spaces allowed in the production date string. Note that the day may be one or two characters long and the month can have any capitalization. The output of the program is a string code that can later be used to generate a bar code for the packaging. It consists of some parts of each of the inputs. The code has the following format: VVV-Mm-fieldID-farmID - VVV holds the first three letters of the variety in uppercase - Mm encodes the first and last letters of the month, with the first letter in uppercase and the last letter in lowercase - fieldID that is the second set of digits in the location ID - farmID that is the first set of digits in the location ID - all subparts of the code are separated with a hyphen (minus sign) "-" As input, let the user enter strings for the variety, location ID, and harvest date, assuming the formatting described above. As output, print the formatted barcode sequence. 1. Create a new NetBeans project called yourname_Lab3. 2. Prompt user to enter the variety. Use Scanner's method nextLine() to read the variety into a String variable. You must read the variety into one variable even if it contains multiple words. Do not use next() method. 3. Prompt user to enter the location ID. Use Scanner's method nextLine() to read the whole location code string into a single String variable. Do not simplify this lab by taking separate user inputs for farmID and fieldID. 4. Prompt user to enter harvest date. Use Scanner's method nextLine() to read the whole date string into a single String variable. Do not simplify this lab by taking separate user inputs for date and month. 5. Checkpoint 1: Print out all the user input variables. Make sure that you have 3 variables that hold the data, and that they are appropriately named. They are all String types. For example: run: Enter the variety: RUBY loose leaf Enter the location ID: 45 iD 8 Enter the harvest date: 22/ March Variety: RUBY loose leaf locationID: 45iD8 Harvest: 22/March BUILD SUCCESSFUL (total time: 2 minutes 17 seconds) 6. Create the pieces of the bar code by extracting various elements of data from the inputs and storing them in appropriately-typed variables. Store individual pieces in separate variables with names indicating what data they hold. A summary of helpful string manipulation methods is provided below. Your task is to figure out how to use those methods to achieve the goal set out in this lab. HINT: you may need to use a combination of methods to find and extract each of the barcode data elements required in this lab. 7. Checkpoints: You should work on each part separately and print out the part of the code to the screen. You may find it useful to print out even subparts of the individual code parts. For example, when finding the first and last letters of the month, one approach is to extract the whole month into a separate variable. Printing the position of the slash and then printing the month string would be a good idea to check that it is correctly extracted: run: Enter the variety: romaine Enter the location ID: 67ID123 Enter the harvest date: 5/ december position of /:1 Month: december BUILD SUCCESSFUL (total time: 17 seconds) Another example is the variety code. Print it out when you obtain the 3 letters and again when you convert them to uppercase: run: Enter the variety: romaine Enter the location ID: 567id12 Enter the harvest date: 5/ april var: rom to upper: ROM BUILD SUCCESSFUL (total time: 21 seconds) 8. Finally, concatenate together all pieces to form the final code, and store the final barcode in one string variable. 9. Print the code to the screen. 10. Make sure that your prompts and output follow the examples in the sample output, including wording, spacing, and punctuation. 11. When your code is working, upload your .java file to the Lab 3 dropbox. SAMPLE OUTPUT run: Enter the variety: tom thumb Enter the location ID: 123id90 Enter the harvest date: 1/MARCH Bar code: TOM-Mh-90-123 BUILD SUCCESSFUL (total time: 20 seconds) run: Enter the variety: TOM THUMB Enter the location ID: 11221D0900 Enter the harvest date: 12/may Bar code: TOM-My-0900-1122 BUILD SUCCESSFUL (total time: 54 seconds) run: Enter the variety: Ruby Loose Leaf Enter the location ID: 4ID2020 Enter the harvest date: 31/JuLY Bar code: RUB-JY-2020-4 BUILD SUCCESSFUL (total time: 1 minute 10 seconds) run: Enter the variety: bibb Enter the location ID: 9083Id451 Enter the harvest date: 25/OctoBER Bar code: BIB-Or-451-9083 BUILD SUCCESSFUL (total time: 1 minute 26 seconds) run: Enter the variety: leaf Enter the location ID: 001ID100 Enter the harvest date: 29/ february Bar code: LEA-Fy-100-001 BUILD SUCCESSFUL (total time: 31 seconds)
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