answer.
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
Likurg_2
1 month ago
5

Assume that the classes listed in the Java Quick Reference have been imported where appropriate.

Computers and Technology
1 answer:
Amiraneli [1K]1 month ago
7 0

The Java code is structured as follows for the specified task

Explanation:

import java.util.*;

class UserName{

  ArrayList<String> potentialNames;

  UserName(String first, String last){

      if(this.isValid(first) && this.isValid(last)){

          potentialNames = new ArrayList<String>();

          for(int i=1;i<first.length()+1;i++){

              potentialNames.add(last+first.substring(0,i));

          }

      }else{

          System.out.println("first and last names must only contain letters.");

      }

  }

  public boolean isTaken(String name, String[] namesArray){

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

          if(name.equals(namesArray[i]))

              return true;

      }

      return false;

  }

  public void setValidUserNames(String[] takenNames){

      String[] names = new String[this.potentialNames.size()];

      names = this.potentialNames.toArray(names);

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

          if(isTaken(takenNames[i],names)){

              int idx = this.potentialNames.indexOf(takenNames[i]);

              this.potentialNames.remove(idx);

              names = new String[this.potentialNames.size()];

              names = this.potentialNames.toArray(names);

          }

      }

  }

  public boolean isValid(String str){

      if(str.length()==0) return false;

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

          if(str.charAt(i)<'a'||str.charAt(i)>'z' && (str.charAt(i)<'A' || str.charAt(i)>'Z'))

              return false;

      }

      return true;

  }

  public static void main(String[] args) {

      UserName user1 = new UserName("john","smith");

      System.out.println(user1.potentialNames);

      String[] usedNames = {"harta","hartm","harty"};

      UserName user2 = new UserName("mary","hart");

      System.out.println("available names before deletion: "+user2.potentialNames);

      user2.setValidUserNames(usedNames);

      System.out.println("available names after deletion: "+user2.potentialNames);

  }

}

You might be interested in
Suppose we are sorting an array of eight integers using quicksort, and we have just finished the first partitioning with the arr
Rzqust [1005]

Answer:

c. The pivot could either be 7 or 9.

Explanation:

When sorting an array of eight integers through quicksort, the first partitioning indicates that either 7 or 9 may serve as the pivot. Observing the array, it is specifically 7 and 9 that occupy their correct positions within the ordered array. All integers preceding 7 and 9 are lesser, and all numbers following them are greater. Therefore, it suggests that the pivot is located between 7 and 9.

6 0
25 days ago
You want to register the domain name ABCcompany.org, but the registration service is not allowing you to do that. What's the mos
amid [910]

Options :

The domain name is already taken.

Domain names are required to end with ".com".

You do not hold legal ownership of ABC Company.

Domain names must exclusively use lowercase letters.

Answer:

The domain name is already taken.

Explanation: In the above scenario, ABCcompany.org signifies the domain associated with a specific individual or organization that leads to the owner's website. Each domain name must be unique; therefore, no two different entities or individuals can have identical domain names. Domains can have endings like .com, .org, .ng, and more, and they are not case-sensitive. Thus, the inability to register the mentioned domain is probably because it has already been claimed by someone else.

6 0
1 month ago
Debug the program so it prints the factorial of a positive integer entered by the user. This is calculated by multiplying all th
Natasha_Volkova [981]
The primary issue was declaring int prod within the while loop, which caused prod to reset to 1 each time the loop executed.
3 0
26 days ago
Which decimal value (base 10) is equal to the binary number 1012?
Natasha_Volkova [981]

Answer:

The decimal representation of 101₂² from base 2 equals 25 in base 10.

Explanation:

To derive the decimal equivalent of 101₂²;

101₂ × 101₂ results in 101₂ + 0₂ + 10100₂.

In this expression, we observe that the '2' in the hundred's place must be converted to '0' while carrying over '1' to the thousand's position, leading to;

101₂ + 0₂ + 10100₂ = 11001₂.

This shows that;

101₂² =  11001₂.

Next, we convert the outcome of squaring the base 2 number, 11001₂, into base 10 through the following method;

Converting 11001₂ to base 10 results in;

1 × 2⁴ + 1 × 2³ + 0 × 2² + 0 × 2¹ + 1 × 2⁰.

The calculation yields;

16 + 8 + 0 + 0 + 1 = 25₁₀.

7 0
1 month ago
Use the following data definitions data myBytes BYTE 10h,20h,30h,40h myWords WORD 3 DUP(?),2000h myString BYTE "ABCDE" What will
Natasha_Volkova [981]

Answer:

Given Data:

myBytes BYTE 10h, 20h, 30h, 40h

myWords WORD 3 DUP(?), 2000h

myString BYTE "ABCDE"

From the supplied information, we can derive that:

(a).     a. EAX = 1

         b. EAX = 4

         c. EAX = 4

         d. EAX = 2

         e. EAX = 4

         f. EAX = 8

         g. EAX = 5

8 0
23 days ago
Other questions:
  • Accenture is helping a large retailer transform their online sales and services. The Data Analyst audits the client’s customer j
    12·1 answer
  • While trying to solve a network issue, a technician made multiple changes to the current router configuration file. The changes
    7·1 answer
  • Start with the following Python code. alphabet = "abcdefghijklmnopqrstuvwxyz" test_dups = ["zzz","dog","bookkeeper","subdermatog
    13·1 answer
  • Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a comma and space. Ex: If hourlyTemp
    6·1 answer
  • Marien is using the Council of Science Editors (CSE) style guidelines to write her research paper. What is her most likely topic
    13·1 answer
  • for question 1-3, consider the following code what is output if the user types in 9? click all that apply A, B, C, D click all t
    13·1 answer
  • A company requires an Ethernet connection from the north end of its office building to the south end. The distance between conne
    8·1 answer
  • On the planet Sigma, robots excavate chunks of a very precious cristaline. These chunks can be divided into smaller part only on
    15·1 answer
  • In 2007, this wireless security algorithm was rendered useless by capturing packets and discovering the passkey in a matter of s
    6·2 answers
  • An application specifies a requirement of 200 GB to host a database and other files. It also specifies that the storage environm
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!