1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Alik [6]
3 years ago
9

JAVA PROGRAMMING

Computers and Technology
1 answer:
VashaNatasha [74]3 years ago
8 0

Answer:

See explaination

Explanation:

import java.util.Scanner;

public class GtldValidation {

public static void main (String [ ] args) {

Scanner scnr = new Scanner(System.in);

// Define the list of valid core gTLDs

String [ ] validCoreGtld = { ".com", ".net", ".org", ".info" };

// FIXME: Define an array named validRestrictedGtld that has the names

// of the restricted domains, .biz, .name, and .pro

String [] validRestrictedGtld={".biz",".name",".pro"};

String inputName = "";

String searchName = "";

String theGtld = "";

boolean isValidDomainName = false;

boolean isCoreGtld = false;

boolean isRestrictedGtld = false;

int periodCounter = 0;

int periodPosition = 0;

int i = 0;

System.out.println("\nEnter the next domain name (<Enter> to exit): ");

inputName = scnr.nextLine();

while (inputName.length() > 0) {

searchName = inputName.toLowerCase();

isValidDomainName = false;

isCoreGtld = false;

isRestrictedGtld = false;

// Count the number of periods in the domain name

periodCounter = 0;

for (i = 0; i < searchName.length(); ++i) {

if (searchName.charAt(i) == '.') {

++periodCounter;

periodPosition = i;

}

}

// If there is exactly one period that is not at the start

// or end of searchName, check if the TLD is a core gTLD or a restricted gTLD

if ((periodCounter == 1) &&

(searchName.charAt(0) != '.') &&

(searchName.charAt(searchName.length() - 1) != '.')) {

isValidDomainName = true;

}

if (isValidDomainName) {

// Extract the Top-level Domain name starting at the period's position. Ex:

// If searchName = "example.com", the next statement extracts ".com"

theGtld = searchName.substring(periodPosition);

i = 0;

while ((i < validCoreGtld.length) && (!isCoreGtld)) {

if(theGtld.equals(validCoreGtld[i])) {

isCoreGtld = true;

}

else {

++i;

}

}

// FIXME: Check to see if the gTLD is not a core gTLD. If it is not,

// check to see whether the gTLD is a valid restricted gTLD.

// If it is, set isRestrictedGtld to true

}

System.out.print("\"" + inputName + "\" ");

if (isValidDomainName) {

System.out.print("is a valid domain name and ");

if (isCoreGtld) {

System.out.println("has a core gTLD of \"" + theGtld + "\".");

}

else if (isRestrictedGtld) {

System.out.println("has a restricted gTLD of \"" + theGtld + "\".");

}

else {

System.out.println("does not have a core gTLD."); // FIXME update message

}

}

else {

System.out.println("is not a valid domain name.");

}

System.out.println("\nEnter the next domain name (<Enter> to exit): ");

inputName = scnr.nextLine();

}

return;

}

}

You might be interested in
Drag each label to the correct location on the image.
andrezito [222]

Answer:

1.) Relative cell reference - A1

2.) Absolute cell reference - $D$2

3.) Mixed cel reference - $D2

Explanation:

In Microsoft Excel, cell references are very important and critical when dealing with formula. They can give you what you’re looking for or make your entire worksheet incorrect.

A cell reference is a cell address or a range of cell addresses that can be used in a formula.

There are three types of cell references and they are;

a) Relative reference

b) Absolute reference

c) Mixed reference

A relative cell reference is a cell reference that changes when you copy the formula to other cells. It s usually just a normal cell reference like A1, B2, C3. If a formula with a relative cell reference is copied down to other cells, the formula will change. That is a formula with a relative cell reference changes with respect to the cell which it is copied to.

An absolute reference does not change when you copy the formula to other cells. In absolute references, the dollar sign $ is used to “lock” both the row and column so that it does not change when it is copied to other cells. An example is $D$2.

Using a mixed cell reference, one is trying to see that only either the row or column changes with respect to other cells when they are copied. It is like “locking” either the column or the row while changing the other. Just like from the example, $D2 is a mixed cell reference where only the column is locked such that only the row changes when the formula is copied to other cells.

7 0
3 years ago
What is star topology
Alexxx [7]
Every node connects to a central network device. like a hub, switch, or computer.
4 0
2 years ago
Read 2 more answers
What is better in everybodys opinion. AMD or Intel?
Rama09 [41]

Answer:

Intel is more for work and such, while AMD is foucsed on gamers. I use AMD because I play many games, but it really depends on what you use your computer for.

Explanation:

4 0
2 years ago
Read 2 more answers
The number of colors in a bitmap image determines which category the image will be in. Complete the following sentences.
Jobisdone [24]

Answer:

Explanation:

1.Grayscale

2.Multitone

7 0
3 years ago
Is anyone else recieving a notification from brainly near the search bar about a message and click it and there nothing there???
Yakvenalex [24]

tessa the same with me I hate it and then I'll click I and then it's blank

4 0
3 years ago
Other questions:
  • If you want to conserve ink or toner, you can instruct PowerPoint to print ____ documents.
    10·1 answer
  • You can upgrade a cpu by adding registers and cache memory to it. <br> a. True <br> b. False
    7·1 answer
  • To what would you compare the transport layer?
    14·1 answer
  • Define critical thinking, and list the mental activities involved in critical thinking.
    8·2 answers
  • I need to know thr full number of pie
    8·1 answer
  • PLEASE HELP WITH MY CODING!!!!!!!!!!!!!!
    7·2 answers
  • Which of the following is not a command for determining if MySQL is running on Linux (Ubuntu)?
    7·1 answer
  • what social media application that affect our day to day activities, and how did it improve our skill
    9·1 answer
  • What are Manuscript signs​
    8·1 answer
  • 2. Which of the following is a shortcut key to Exit from any operation?
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!