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]
4 years ago
9

JAVA PROGRAMMING

Computers and Technology
1 answer:
VashaNatasha [74]4 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
I want to do is speed test to do i go to for my computer
laiz [17]

I just go to the speed test on my browser

7 0
3 years ago
Benching system are prohibited in
enyata [817]
Providence yep ur welcome
3 0
3 years ago
What is the function of a computer screen?
Leni [432]

Hi!

A computer screen is what you are staring at right now!

It displays the output. Behind it are wires and cords.



~CoCo

7 0
4 years ago
If you want to create programs with more detailed images, maybe even characters that you could interact with, what pieces of inf
Oliga [24]

The pieces of information needed in the code to create a more detailed program are the sprite objects

<h3>What are sprites?</h3>

Sprites are program objects that are used in a program to add more features such as detailed images, characters and animations in the program.

The sprite objects are dragged and dropped on the program

Hence, the pieces of information needed are the sprite objects

Read more about object-oriented program at:

brainly.com/question/25649719

6 0
2 years ago
The "Father of the Computer" was _____________, an Englishman, who in 1836 produced designs for a "computer" that could conduct
Leviafan [203]

Answer:

Charles Babbage is the correct answer to the following question.

Explanation:

Charles Babbage is the person who invented the computer, but he failed to build the computer system and the first engine was finished in year 2002 in London, after 153 years of his death but he was an inventor and the father of the automatic computing engines.

So, that's why he was called as the "Father of Computer".

5 0
3 years ago
Other questions:
  • A _____________ is some text or data that is stored on your computer and used by a website to track how you use that site. quest
    8·2 answers
  • How many steps are there on Mail Merge Task Pane? List them.​
    9·1 answer
  • What are the examples of shareware?
    9·2 answers
  • When designing a suitable and safe flexibility training program, you should set reasonable and appropriate goals depending on wh
    15·1 answer
  • Although you are not a full administrator, you are asked to manage a protected document, allowing customized access to any inter
    7·1 answer
  • An object contains data and the instructions that manipulate the data (Points : 2) True
    8·1 answer
  • A cookie filter blocks the sending and receiving of cookies. Blocking cookies can reduce some threats of session tracking and id
    12·1 answer
  • Academic databases are the best place to look for
    12·1 answer
  • When would you use the AutoFit to Contents option?
    15·1 answer
  • What is the purpose of flight simulator programs, and what are some of the benefits of using them?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!