Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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 company that provides map services (much like Google Maps). 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). You are working in the consulting area of the company, and your current client is FIU. The university is asking for a custom mapping application. Your first task is to parse out the different parts of URL for requests. 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: - This is the method used to transfer information across the internet. Valid values for protocol include the following: http, https, ftp, and mailto, but could be any word of any length (excluding the special punctuation characters). - Domain information: - 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. Domain: - This is the string you purchase from a domain name registry to identify your server on the web. - 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. Punctuation hint: - The dot ": character separates the subdomain from the domain name, and the domain name from the TLD. - The domain parts can be of any length and contain any characters except the dot ".' and the forward slash ' %. - Query parameters o First parameter: univ - This identifies the university using a university code. Examples: "FIU", "UF", "NDSU". - The name "univ" for the parameter is fixed but can be in any case. - This parameter is always going to be the first parameter in the URL string. - Second parameter: map - Latitude and Longitude: these are the data values that serve as input to the map query, and describe the geographic point the requestor would like mapped. Latitude is the first value, and longitude is the second value. - The name "map" for the parameter is fixed but can be in any case. - This parameter is always going to be the second parameter in the URL string. The special punctuation characters have special function, here are the hints that will help you locate the different parts of the URL string: - The string "://" separates the protocol from the rest of the URL - The question mark '?' character separates the domain information from the query parameters. - The ' = ' character separates the parameter name from the parameter value for both parameters. - The ' & ' character separates the first parameter from the second parameter. - The pipe 'l' character separates the latitude and longitude values for the map parameter. The university would like the mapping application to react differently for map points within the boundary formed by FIU and Tamiami Park. Thus, your second task involves checking whether the map point defined by the latitude and longitude values in the URL lies within a box formed by SW 8th Street on the north, 107th Avenue on the east, Coral Way on the south, and 117th Avenue on the west. The latitude and longitude values corresponding to these roadways are shown on the map below: The North, South, West, and East edge boundary values for latitude and longitude should be defined as class-level constants in the code. Your third task involves creating a specific output for the case when the user requests FIU as the university and at the same time the map point falls within the defined rectangle: - Print "FIU location requested" if the univ parameter in the URL contains the value "FIU" (in any case) AND the latitude and longitude point lies within the box defined above. - In all other cases, print "Conditions not met" Your final code should do the following: - As input, prompt the user to 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. - Print "FIU location requested" or "Conditions not met", based on the content of the URL values in the input string. 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 descriotions of a set of methods vou mav find useful in this assignment: Instructions: 1. Create a new NetBeans project called yourname_assignment2 2. Define class-level constants for the four values that specify the map's boundary edges. 3. Prompt the user to enter a URL string. 4. Read the input from the keyboard, and store it in a String variable. 5. 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 - Store each data element to an appropriately-typed variable - Include only the text portions for each data element, do not include the URL punctuation. - HINT: for some of the 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. Checkpoints: As you work through the URL string, there are many points where intermediary variables should be checked for a correct value. Print out helpful information for debugging to the screen. For example, print the position of found punctuation character and check that it is what you expect. Then leave the printing line in the source code and comment it out. 6. Once you have all the data parts in the their respective variables, print them out to the screen, as seen in this example: run: Enter the URL: http://Eiu. instructure . com/?univ=IU / map=25.757195/-80.375829 Protocol: http Subdomain: Eiu Domain: instructure Top-level: com Univeraity: FIU Map request: 25.757195180.375829 Latitude as string: 25.757195 Longitude as string: 80.375829 BUILD SUCCEsSmUL (total time: 0 seconds) 7. Convert the latitude and longitude values to double-typed variables (see the Double.parseDouble (String s) method in the table) and store them in double variables. 8. Determine whether the requested map point lies within the FIU's boundary rectangle. You will need to make decisions for both the latitude and longitude components and only if both components are within their limits, the point is in the rectangle. Make sure the limits are class-level constants. - HINT: Instead of creating a one long and complex Boolean expression, break it down into smaller expressions and save their results in Boolean variables. Then use those variables in the final expression that determines whether the longitude and latitude components satisfy the limits concurrently. 9. Determine whether the value of the University parameter is "FIU" (in any case). 10. Print out the "FIU location requested" string if both university parameter and the map request parameter satisfy the conditions. Otherwise, print "Conditions not met". 11. Check that your final printout matches the sample output. Test multiple URL strings. Be sure to match your output to the sample, including wording, spelling, spacing, and punctuation. Grading points: - Use of class-level named constants - Use of variables with meaningful names and correct types - Input of data with user prompts - Correctness of math calculations - Correctness of Boolean logic (ifs) - Conformance of output to sample output - Code organization (input/processing/output) - Code alignment (indentation) 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/?univ=FIU\&map =25.75719580.375829 https://www.example.gov/?UNIV=Fiu\&MAP =24.66464882.885596 ftp:// www.maprequest.pictureframe/?univ=fiu\&map =25.65624880.376633 ftp:// www.maprequest.pictureframe/?univ=FSU\&map =25.75719580.375829 WWW://SERVICE.DOMAINNAME.TOPLEVEL/?UNIV=fiu\&MAP =25.74780.369 HINT: o Instead of repeatedly entering these strings as user input when developing the code, declare a string variable, set its value in the source code to one of the examples, and use this variable for as the URL string. After your code is tested and works on all test strings, revert back to asking the user to enter the URL. SAMPLE OUTPUT run: Enter the URL: http://fiu.instructure.com/2univ=IIU6map=25. 757195180.375829 Protocol: http Subdomain: fiu Domain: instructure Top-level: com University: EIU Map request: 25.757195180.375829 Latitude as string: 25.757195 Longitude as atring: 80.375829 FIU location requested BUILD SUCCESSzUL (total time: 0 seconds) run: Znter the URL: https://www.example . gov/ ?UNIV=FiucMAP=24. 664648|-82. 885596 Protocol: httpa Subdomain: wwe Domain: example Top-1evel: gov Univeraity: FIU Map request: 24.664648182.885596 Latitude as string: 24.664648 Longitude as string: 82.885596 Conditions not met BUILD SUCCEsSTUL (total time: 0 seconds) run: Enter the URL: ftp://wrw. maprequest.pictureframe/?univ=fiu6map=25.656248 180.376633 Protoco1: ftp Subdomain: whw Domain: maprequest Top-level : pictureframe University: FIU Map request: 25.656248180.376633 Latitude as string: 25.656248 Longitude as string =80.376633 Conditions not met BUILD SUCCESSTUL (total time: 0 seconds) run: Enter the URL: ftp://ww - maprequest. pictureframe/ ?univ=FSU dmap=25. 757195180.375829 Protocol: ftp Subdomain: Www Domain: maprequest Top-level : pictureframe University: FSU Map request: 25.757195180.375829 Latitude as string: 25.757195 Longitude as atring: 80.375829 Conditions not met BUILD SUCCESSFUL (total time: 0 geconds) run: Enter the URL: WWW : //SERVICE. DOMAINNAME. TOPLEVEL/ ?UNIV=tiu6MAP=25. 747/-80.369 Protocol: WWW Subdomain: SERVICE Domain: DOMAINNAME Top-leve1: TOPLEVEL University: FIU Map request: 25.747180.369 Latitude as string: 25.747 Longitude as string: 80.369 FIU location requested BUILD SUCCESSIUL (total time: 0 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

Privacy In Statistical Databases International Conference Psd 2022 Paris France September 21 23 2022 Proceedings Lncs 13463

Authors: Josep Domingo-Ferrer ,Maryline Laurent

1st Edition

3031139445, 978-3031139444

More Books

Students also viewed these Databases questions