Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

LANGUAGE TO USE: JAVA Your current task is in helping to prepare the incoming data for the analytics process, specifically looking at a set of

LANGUAGE TO USE: JAVA

image text in transcribed

image text in transcribedimage text in transcribed

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: Protocol Domain Query File pe to weat resource File path to web Protocol Domain page http://fiu.instructure.com/folder/folder/folder/app?map=25.757195 -80.375829 21 Subdomain Top-level Web page Latitude Latitude Longitude Longitude domain 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. Punctuation hint: the string"://" separates the protocol from the rest of the URL 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 Punctuation hint: the dot'!' character separates the subdomain from the domain name, 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 Punctuation hint: the slash '/' character separates each string in the file path, up to the 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 Punctuation hint: the question mark?' character separates the file path and web page 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 Punctuation hint: the equals '=' character separates query resource name from the data input values. o Punctuation hint: the pipe 'l' character separates the latitude and longitude values. Latitude is the first value, and longitude is the second value. Instructions: 1. Create a new NetBeans project called yourname_assignment2 2. Prompt the user to enter a URL string. 3. Read the input from the keyboard, and store it in a String variable. 4. For each of the nine parts of the URL, pull the data element of interest out of the URL. o Use the methods in the table on the previous page to do the following: . Use the punctuation in the URL to locate each data element o o . Store each data element to an appropriately-typed variable include only the text portions for each data element, do not include the URL 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. HINT: for some of these elements, you will not be able to get to the data with a single method call to one of the methods in the table. Instead, you will need to invoke a combination of these methods to parse the needed information from the input string. If you cannot identify a single method that does what you need, then start considering combinations of methods to reach the desired data. HINT: there are many possible ways to encode this logic. Your approach may not be the same as other classmates' approaches. As long as your logic meets the requirements in this specification, it's a good approach. HINT: you may not need all of the methods listed in the table, but all are potentially useful. o 5. 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. 6. Print out the results, following the examples in the sample output. Be sure to match your output to the sample, output, output wording, spacing, and punctuation. SAMPLE OUTPUT run: Enter the URL: http://fiu. instructure.com/folder/folder/folder/app?map=25.757195-80.375829 Protocol: http Subdomain: fiu Domain: instructure Top-level: com Folder path: folder/folder/folder Web page: app Resource: map Latitude: 25.757195 Longitude: -80.375829 Latitude plus 1: 26.757195 Longitude plus 1: -79.375829 BUILD SUCCESSFUL (total time: 3 seconds)

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

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

Recommended Textbook for

More Books

Students also viewed these Databases questions