basic java coding lab. Due tonight at 11:59, super easy
ISM3230In-class lab Module 3 – Working with Strings and String Methods Spring 2021
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.
o 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.
o 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.
o 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:
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.
o 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.
o 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:
Another example is the variety code. Print it out when you obtain the 3 letters and again when
you convert them to uppercase:
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.
String manipulation methods
Method Return
Type
Description
concat(String str) String Concatenates the specified string to the end of this string.
indexOf(String str) int Returns the index within this string of the first occurrence of
the specified substring.
indexOf(String str, int fromIndex) int Returns the index within this string of the first occurrence of
the specified substring, starting at the specified index.
lastIndexOf(String str) int Returns the index within this string of the last occurrence of
the specified substring.
length() int Returns the length of this string.
substring(int beginIndex) String Returns a new string that is a substring of this string. The
substring begins with the character at the specified index
and extends to the end of this string.
substring(int beginIndex, int endIndex) String Returns a new string that is a substring of this string. The
substring begins at the specified beginIndex and extends to
the character at index endIndex – 1.
toUpperCase() String Converts all of the characters in this String to upper case.
toLowerCase() String Converts all of the characters in this String to lower case.
SAMPLE OUTPUT
We provide professional writing services to help you score straight A’s by submitting custom written assignments that mirror your guidelines.
Get result-oriented writing and never worry about grades anymore. We follow the highest quality standards to make sure that you get perfect assignments.
Our writers have experience in dealing with papers of every educational level. You can surely rely on the expertise of our qualified professionals.
Your deadline is our threshold for success and we take it very seriously. We make sure you receive your papers before your predefined time.
Someone from our customer support team is always here to respond to your questions. So, hit us up if you have got any ambiguity or concern.
Sit back and relax while we help you out with writing your papers. We have an ultimate policy for keeping your personal and order-related details a secret.
We assure you that your document will be thoroughly checked for plagiarism and grammatical errors as we use highly authentic and licit sources.
Still reluctant about placing an order? Our 100% Moneyback Guarantee backs you up on rare occasions where you aren’t satisfied with the writing.
You don’t have to wait for an update for hours; you can track the progress of your order any time you want. We share the status after each step.
Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.
Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.
From brainstorming your paper's outline to perfecting its grammar, we perform every step carefully to make your paper worthy of A grade.
Hire your preferred writer anytime. Simply specify if you want your preferred expert to write your paper and we’ll make that happen.
Get an elaborate and authentic grammar check report with your work to have the grammar goodness sealed in your document.
You can purchase this feature if you want our writers to sum up your paper in the form of a concise and well-articulated summary.
You don’t have to worry about plagiarism anymore. Get a plagiarism report to certify the uniqueness of your work.
Join us for the best experience while seeking writing assistance in your college life. A good grade is all you need to boost up your academic excellence and we are all about it.
We create perfect papers according to the guidelines.
We seamlessly edit out errors from your papers.
We thoroughly read your final draft to identify errors.
Work with ultimate peace of mind because we ensure that your academic work is our responsibility and your grades are a top concern for us!
Dedication. Quality. Commitment. Punctuality
Here is what we have achieved so far. These numbers are evidence that we go the extra mile to make your college journey successful.
We have the most intuitive and minimalistic process so that you can easily place an order. Just follow a few steps to unlock success.
We understand your guidelines first before delivering any writing service. You can discuss your writing needs and we will have them evaluated by our dedicated team.
We write your papers in a standardized way. We complete your work in such a way that it turns out to be a perfect description of your guidelines.
We promise you excellent grades and academic excellence that you always longed for. Our writers stay in touch with you via email.