Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have successfully met all the requirements for this question except the last number 3. What is the solution? Below is my code: import java.util.Scanner;

image text in transcribedI have successfully met all the requirements for this question except the last number 3. What is the solution?

Below is my code:

import java.util.Scanner;

public class SearchForDomainName {

public static void main(String [ ] args) { Scanner scnr = new Scanner(System.in); String inputName; String searchName; String coreGtld1; String coreGtld2; String coreGtld3; String coreGtld4; // FIXME: Add a fourth core gTLD: .info boolean isCoreGtld;

coreGtld1 = ".com"; coreGtld2 = ".net"; coreGtld3 = ".org"; coreGtld4 = ".info"; isCoreGtld = false;

System.out.println(" Enter a top-level domain name: "); inputName = scnr.nextLine(); // Case is irrelevant, so make all comparisons with lower case searchName = inputName.toLowerCase();

// FIXME: Allow the user to enter a name with or without a leading period

// Determine whether the user-entered name is a gTLD if (searchName.compareTo(coreGtld1) == 0) { isCoreGtld = true; } else if (searchName.compareTo(coreGtld2) == 0) { isCoreGtld = true; } else if (searchName.compareTo(coreGtld3) == 0) { isCoreGtld = true; } else if (searchName.compareTo(coreGtld4) == 0) { isCoreGtld = true; } // FIXME: Add a check for the fourth domain name else { isCoreGtld = false; }

System.out.print("The name \"" + inputName + "\" "); if (isCoreGtld) { System.out.println("is a core gTLD."); } else { System.out.println("is not a core gTLD."); }

return; } }

zyDE 4.16.1: Search for name using branches. A core generic top-level domain (core gTLD) name is one of the following Internet domains: .com, .net, .org, and .info (ICANN: gTLDs). The following program asks the user to input a name and prints whether that name is a gTLD. The program uses the String method compareTo(), which returns a zero if the two compared strings are identical. 1. Run the program, noting that the .info input name is not currently recognized as a gTLD. 2. Extend the if-else statement to detect the .info domain name as a gTLD. Run the program again. 3. Extend the program to allow the user to enter the name with or without the leading dot, so .com or just com. Load default template.. \begin{tabular}{|r|l} \hline 6 & Scanner scnr = new Scanner(System.in); \\ 7 & String inputName; \\ 8 & String searchName; \\ 9 & String coreGtld1; \\ 10 & String coreGtld2; \\ 11 & String coreGtld3; \\ 12 & String coreGtld4; \\ 13 & I/ FIXME: Add a fourth core gTLD: .info \\ 14 & boolean isCoreGtld; \\ 15 & \\ 16 & coreGtld1 = ". com"; \\ 17 & coreGtld2 = ".net"; \\ 18 & coreGtld3 = ".org"; \\ 19 & coreGtld4 = ".info"; \\ 20 & isCoreGtld = false; \\ \hline 1 & \\ \hline com & \\ \hline \end{tabular}

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

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago