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
Answer for 3.4.8 rectangle code HS
tigry1 [53]

Answer:

i think Make variables to represent the length and width of a rectangle, called length

and width

, respectively. You should set length

to 10 and width

to 5.

Then, write some mathematical expressions to computer the area and perimeter of the rectangle and save these values inside variables named area and perimeter

.Use print

statements to display the area and perimeter of the rectangle.

Your output should print the area on the first line and the perimeter on the second, like this:

50 30  Rectangle Area Formula:

Area = L * W

Explanation:

7 0
2 years ago
Application area of word processor?​
kompoz [17]

Answer:

  1. Typing, editing,and printing different types of document .
  2. Formatting text, paragraph , pages for making attractive document .
  3. Checking spelling and grammar of document for making it error free.
  4. Inserting and editing pictures , objects, etc.
  5. Adding watermark , charts , quick flip, etc.
7 0
3 years ago
Read 2 more answers
Translate the following pseudocode for randomly permuting the characters in a string into a C++ program.
Svetllana [295]

Answer:

d

Explanation:

salak sensin kolay gelsin

6 0
2 years ago
Suppose a program is operating with execution-time binding and the physical address generated is 300. the relocation register is
maria [59]

The corresponding logical address is 200.

If a program is operating with execution-time binding, the physical address generated will be 300. However, if the relocation register is set to 100, the corresponding logical address will be 200.

This is because the relocation register is used to offset the physical address, so that it can be used to calculate the logical address.

Learn more here:

brainly.com/question/20355023

#SPJ4

7 0
1 year ago
Which of the following is NOT a place where you are likely to encounter a pedestrian?
AlexFokin [52]

Answer:

A. On a highway

Explanation:

On a highway is NOT a place where you are likely to encounter a pedestrian.

Pedestrians found on highways usually get arrested or get a ticket.

3 0
2 years ago
Read 2 more answers
Other questions:
  • The git _____ command will display the last commit and what were the changes you made.
    9·1 answer
  • What coding scheme is used by most microcomputers?
    11·1 answer
  • A design tool helps you plan, evaluate, and explain your ideas to create a product. Some examples of design tools are outlines,
    10·2 answers
  • Data governance consists of? A. the processes, methods, and techniques to ensure that data is of high quality, reliable, and uni
    11·1 answer
  • The internet maybe best compared to what
    11·1 answer
  • They are correct? thank you!
    6·2 answers
  • A source mainly provides <br> from a text or piece of media.
    6·2 answers
  • You want a cable that could be used as a bus segment for your office network. The cable should also be able to support up to 100
    5·1 answer
  • Types of computer viruses<br>​
    5·2 answers
  • RUNTIME ORGANIZATION AND DATA LAYOUT.​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!