Answered You can hire a professional tutor to get the answer.
You are working for a company that provides map services (much like Google Maps), and you are working in the analytics area of the company.
You are working for a company that provides map services (much like Google Maps), and you are working in the analytics area of the company. Your company's services are not directly web-accessible; rather, other web sites call for maps, and embed the results in their content (and pay for the privilege of doing so). Your group is working on applications that will be used for strategic analysis and decision- making for the sales and marketing group in negotiating new contracts, and re-negotiating old ones.
Your current task is in helping to prepare the incoming data for the analytics process, specifically looking at a set of URL data, and parsing out the different parts. In other words, you will be writing code to pull data items from the input URL string, and store them as separate data elements.
URLs look like this:
Your analytics group is interested in the following parts of the URL. The punctuation hints provided here will help you locate the different parts of the URL string from your code.
- Protocol: this is the method used to transfer information across the internet. Valid values for protocol include the following: http, https, ftp, and mailto.
- o Punctuationhint:thestring"://"separatestheprotocolfromtherestoftheURL
- Domain: this is the string you purchase from a domain name registry to identify your server
- Top-level domain (TLD): each top-level domain is controlled by a domain name registry. Familiar
- TLDs include .com, .edu, and .gov; however, almost any text string can now be used as a TLD, e.g., .valentine, .horsehair, or .frostbite. A domain name plus a TLD serves as a unique identifier for locating your server on the internet, so that the world can find your content or application.
- Subdomain: this identifies a portion of content or logic available at this URL. For example, fiu.instructure.com identifies FIU's Canvas content among all other universities' Canvas courses on the instructure.com site.
- o Punctuationhint:thedot'.'characterseparatesthesubdomainfromthedomainname, and the domain name from the TLD.
- Web page: this identifies the content (static web page) or application logic (dynamic web page) that the user asks for
- File path: this identifies how the server locates the web page to serve. This could be an actual folder path on the server, or some other way the site is using to identify what to serve.
- o Punctuationhint:theslash'/'characterseparateseachstringinthefilepath,uptothe web page name.
- Query: this identifies what resource is requested. In this scenario, we're looking at map queries, but your company may also support general text search, or product search, or other services. (So your code should not be hard-coded solely for map queries.)
- o Punctuationhint:thequestionmark'?'characterseparatesthefilepathandwebpage name from the query-related data.
- Latitude and Longitude: these are the data values that serve as input to the map query (the data values in the example URL point to the FIU main campus...).
o Punctuationhint:theequals'='characterseparatesqueryresourcenamefromthedata input values.
o Punctuationhint:thepipe'|'characterseparatesthelatitudeandlongitudevalues. Latitude is the first value, and longitude is the second value.
As input, prompt the user enter a URL.
As output, print each data element you have parsed from the URL, following instructions below, and using the sample output as an example.
As you work through the instructions below, refer to slides in 3c_stringVariablesAndValues.pdf and 3d_stringMethods.pdf from today's class material for help with character indexing and the specifics on how String variables and String methods work.
The following table provides descriptions of a set of methods you may find useful in this assignment:
Class
Method
Return Type
Description
String
indexOf(int ch)
int
Returns the index within this string of the first occurrence of the specified character.
String
indexOf(int ch, int fromIndex)
int
Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.
String
indexOf(String str)
int
Returns the index within this string of the first occurrence of the specified substring.
String
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.
String
lastIndexOf(int ch)
int
Returns the index within this string of the last occurrence of the specified character.
String
lastIndexOf(int ch, int fromIndex)
int
Returns the index within this string of the last occurrence of the specified character, searching backward starting at the specified index.
String
lastIndexOf(String str)
int
Returns the index within this string of the last occurrence of the specified substring.
String
lastIndexOf(String str, int fromIndex)
int
Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the specified index.
String
substring(int beginIndex)
String
Returns a new string that is a substring of this string.
String
substring(int beginIndex, int endIndex)
String
Returns a new string that is a substring of this string.
Double
parseDouble(String s)
double
Returns a new double initialized to the value represented by the specified String.
Instructions:
- Prompt the user to enter a URL string.
- Read the input from the keyboard, and store it in a String variable.
- For each of the nine parts of the URL, pull the data element of interest out of the URL.
o Usethemethodsinthetableonthepreviouspagetodothefollowing:§ Use the punctuation in the URL to locate each data element§ Store each data element to an appropriately-typed variable
o Includeonlythetextportionsforeachdataelement,donotincludetheURL punctuation.
§ Exception: for the file path, you should omit the start and end slash '/' characters, but retain the internal slashes that delineate the parts of the file path.
o HINT: you will need more than one method to pull data elements out of the URL. What information do you need before you can assign the data element to a result variable?
o HINT:therearemanypossiblewaystoencodethislogic.Yourapproachmaynotbethe same as other classmates' approaches. As long as your logic meets the requirements in this specification, it's a good approach.
o HINT:youmaynotneedallofthemethodslistedinthetable,butallarepotentially useful.
- Convert the latitude and longitude values to double-typed variables (using the parseDouble method in the table). To prove that you are working with numbers rather than Strings, add 1 to each value, and store the results to new double variables.
- Print out the results, following the examples in the sample output. Be sure to follow these examples closely, including output wording, spacing, and punctuation.
- When your code is working, upload your .java file to the Assignment 2 dropbox.
SAMPLE INPUT
The following sample input is provided to give you a few test cases. Please keep in mind that your code will be tested with input beyond these strings.
http://fiu.instructure.com/folder/folder/folder/app?map=25.757195|-80.375829 https://www.example.gov/folder1folder1folder1/application?search=24.664648|-82.885596 ftp://www.maprequest.pictureframe/la/di/dah/mapApp?map=25.656248|-80.766333
SAMPLE OUTPUT