Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

work within the main method in UrlInterpreter.java. Inspect the existing code in UrlInterpreter.java which does the following: - Prompts the user to enter a


 

 work within the main method in UrlInterpreter.java. Inspect the existing code in UrlInterpreter.java which does the following:

 

- Prompts the user to enter a String url - reads this in and stores it You should not read in any more information from the user. Based on the url provided from the user in the existing code, your task is the following:

1. Create a new Url object named urlObject (using the Url class mentioned above). 2. Set urlObject's completeUrl attribute the the local String variable url provided by the user. 3. Set urlObject's domain, isNonProfit, and isSecure attributes to the correct values. This step will require

decision-making and "breaking apart" the url String. Hints are provided below: a. To populate the domain - you'll need to extract it from the url String

i. Think of what methods you can use in the String class to do this - and if there are any special characters in the url syntax that tell us, as humans, where the domain is located.

1. Hint: indexOf(char), lastIndexOf(char), substring(int,int), and substring(int) are all helpful String class methods! Look these up in zyBooks / the Java API to understand how to use them!

b. To populate the isNonProfit and isSecure attributes - you'll also need to use extract information from the url String - and use decision (branching) statements to set the values to true or false based on the url syntax.

4. Call the printUrlInfo method with the urlObject to print the url data to the console Before submitting - run this several times, testing that the printed output is correct. You should delete any other println statements used for testing before submitting. Submit your code for Part 2.

Step by Step Solution

3.40 Rating (159 Votes )

There are 3 Steps involved in it

Step: 1

It looks like you have a task to complete within the main method of the UrlInterpreter class Based o... 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

Programming Logic And Design Introductory

Authors: Joyce Farrell

8th Edition

1285845773, 978285845777

More Books

Students also viewed these Programming questions

Question

How do people develop skills?

Answered: 1 week ago