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
Which statement about the Weather Bar in the Outlook calendar is true?
NARA [144]

Answer:

C

Explanation:

3 0
3 years ago
While (e &lt; 10):<br> print (c)
Ymorist [56]

Answer:

Huh? can you ask a real question so I can answer?

Explanation:

7 0
3 years ago
Jenna updated her status on a social network regarding her upcoming vacation. What information should Jenna not provide when upd
Helen [10]
Jenna should NOT provide her routine!!!
hope this helps and have a great day!!
7 0
3 years ago
Read 2 more answers
Discuss any five focus areas<br> for Green Computing you can concentrate on
BaLLatris [955]

Answer:

Five focus areas for Green Computing are:

  1. Environmental conditions
  2. Information technology (IT) systems
  3. Cooling systems
  4. Electrical systems
  5. Air management systems

Explanation:  

Green computing refers to the art of managing very effectively information technology such that the current level of productivity is maintained or exceeded.

Many of the factors listed above are more typical to data centers.

Data centers are IT systems that consume lots of electricity whilst generating lots of heat.

Sustained over a long period of time, the heat generated will contribute to green-house gases as the cooling system that is required to keep the data houses cool are big.

Hence, the green computing protocol requires where possible, minimal electricity be expended in cooling the data warehouses.

Another suggestion that has been given is for systems and appliances to be shut down when not in use rather than being left on or on standby.

Cheers

8 0
3 years ago
Where does the list of incoming mail appear in gmail
k0ka [10]
In your inbox,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,..,.,
5 0
4 years ago
Read 2 more answers
Other questions:
  • peter has recently bought a media player and a digital camera. he wants to buy a memory card for these devices. which memory dev
    11·1 answer
  • What New England industry quickly collapsed with the discovery of oil in Pennsylvania?
    11·2 answers
  • Why are rules required for a number system to be useful?
    10·2 answers
  • What is an advantage and disadvantage to file compression
    8·1 answer
  • Which of the following is the best name for a history report about World War I?
    7·2 answers
  • Summarise all what you know about spss​
    15·1 answer
  • What does the image depict:
    14·1 answer
  • Pick one<br>a. wonder Woman <br>b. super woman​
    7·2 answers
  • NO LINKS Please
    8·2 answers
  • can anyone yell how to save the python file in folder i am saving it but whenever I'm trying to open its not open​
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!