Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 of 3 ISM3230 In-class lab Module 3-Working with Strings and String Methods Spring 2019 TASK At the ice cream production company, you are helping

image text in transcribed
image text in transcribed
image text in transcribed
1 of 3 ISM3230 In-class lab Module 3-Working with Strings and String Methods Spring 2019 TASK At the ice cream production company, you are helping to build a system for distributing ice cream to grocery stores across the country. Your task involves transforming production data into an intermediary code that is later sent into a bar code generator. 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 two 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 flavor of the ice cream. This could be any word or sequence of words. Flavor names are guaranteed to be at least 4 letters long. Flavor examples are: "chocolate", "Vanilla", "Chocolate Chip, "MINT, "Green TEA", etc. . The production date of the ice cream batch. This comes in a format of day/month/year, where day is a number between 0 and 31, month is a full name of the month (February, July, etc.), and year is a 2-digit or 4-digit number. Examples of production dates are: "1/February/2017 15/MARCH/18", "31/december/2019. Each part of the date string is separated by a character. There are no spaces allowed in the production date string. . 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: YY-FFF-Mm-h YY is the 2-digit year of production FFF are the first 3 letters of the flavor name in uppercase Mm encodes the first and second letters of the month, with the first letter in uppercase and the second letter in lowercase e h encodes the last letter of the month in lowercase all subparts of the code are separated with a hyphen (minus sign) As input, let the user enter strings for the flavor and production 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 flavor. Use Scanner's method nextLine() to read the flavor into a string variable. You must read the flavor into one variable even if it contains multiple words. o Do not use next() method. 3. Prompt user to enter production 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, month, and year 4. Create the pieces of the ice cream code by extracting various elements of data from the inputs and storing them in appropriately-typed variables 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 In this lab, everything is a String. The production year is not a number and you should work with it as a String. o . Finally, concatenate together all pieces to form the final code, and store the final barcode in one string variable 6. Print the code to the screen. 7. Make sure that your prompts and output follow the examples in the sample output, including wording, spacing, and punctuation. 8. When your code is working, upload your .java file to the Lab 3 dropbox. String manipulation methods: Use the following methods of the String class to do the string manipulation. There can be multiple ways to achieve the same result. Not all of these methods are necessary to complete the assignment, but all could potentially be useful, depending on how you approach the task: Return Description concat(String str) Concatenates the specified string to the end of this strin Returns the index within this string of the first occurrence of the Returns the index within this string of the first occurrence of tri int indexOf(String str) indexOf(String str, int fromindex) lastindexOf(String str) ified substr int ied substring, starting at the s index Returns the index within this string of the last occurrence of the Returns the I int ified subst int of this strin 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 stri substring(int beginindex, int endindex) String Returns a new string that is a substring of this string. The substring begins at the specified beginlndex and extends to the character at index endindex-1 Converts all of the characters in this String to u Converts all of the characters in this String to lower case rCas tri Stri r case toLowerCase zun Enter the ice cream flavor: vaniila Enter the production date: 30/Apri1/22 Bar code: 22-VAN-Ap-1 BUILD SUCCESSFUL (t tal time : 27 ecords ) zun Enter the ice cream flavor: Chocolate Enter the production date: 4/december/16 Bar code: 16-CHO-De-r BUILD SUCCESSFUL (total time: 13 seconds) zun Enter the ice cream tlavor: green tea Enter the production date: 0/August/2022 Bar code: 22-GRE-Au-t BUILD SUCCESSFUL (total time : 17 ecords) zun Enter the ice cream flavoz MINT Enter the production date /JULY/2013 Bar code: 13-MIN-Ju-y BUILD SUCCESSFUL (total time: 14 seconds) zun Enter the ice cream flavor Fruit Mix Enter the production date 1/MARCH/2000 Bar code: 00-FRU-Ma-h BUILD SUCC SSFUL (total time : 54 econd )

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions