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
Suppose you are given a sequence that is described by a formula, starting at index n=0. If you need to change the starting index
Arisa [49]

Answer:

n+1

Explanation:

Given

n = 0 --- starting index

Required

Change the starting index to n = 1

We have:

n = 0

To change the starting index to k, we simply rewrite as:

n+k

<em>In this case; k=1; so, the starting index will be: </em>n+1<em />

3 0
3 years ago
WHY IS BRAINLY NOTIFICATIONS LIKE THIS?????
nikdorinn [45]

Answer:

probly the wifi connection

Explanation:

4 0
3 years ago
Read 2 more answers
TRUE OR FALSE!!!!!
VladimirAG [237]
The answer is True.
6 0
3 years ago
Read 2 more answers
Ken Olson, president of Digital Equipment Corp. in the late 1970's, Thomas J. Watson, chairman of IBM in the early 1940's, and T
tensa zangetsu [6.8K]

Answer:

All of the above is the correct answer to the given question .

Explanation:

As the Ken olson is the Ken Olson, president of the Digital Equipment Organization . Following are the predictions of  Ken olson of the the technology that are wrong.

  • Lack of creativity regarding the current applications that the user has would consider for the  technology.
  • Lack of creativity regarding the  user or the client has liking.
  • Lack of creativity on what the government would be charging ford. Any of these

So we will choose the Option all these.

8 0
3 years ago
1) what are two functions of a pick or count condition?
anastassius [24]
1. The answer is C. Pick an object at random, and keep track of how many copies of an object are left in a game.

2. The answer is D. Clockwise and counter clockwise.

3. The answer is B. To play an object's animation.

I hope you find this helpful.
5 0
3 years ago
Other questions:
  • Mrs. Golden wanted to collect baseline data on how often Lauren speaks to her neighbors during silent reading. He divided the 15
    9·1 answer
  • The layout gallery displays 10 slide layouts with a variety of placeholders to define text and content positioning and formattin
    13·1 answer
  • Which term describes the process by which light passes through an object or a medium.
    7·2 answers
  • Who have a ps4 ?<br> Who have 2k20? <br> Are you good a 2k20 ? <br> Add me on Ps4 eoKyriie
    13·2 answers
  • Complete each sentence to describe different elements of an Excel worksheet.
    11·2 answers
  • Following the car in front of you at a closer distance _____.
    6·2 answers
  • Brainliest
    13·2 answers
  • Guys im getting the ps5 tomorrow :)​
    5·2 answers
  • Help me
    5·1 answer
  • What are basic types of touch screen
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!