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
mart [117]
2 years ago
5

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

Computers and Technology
1 answer:
Neko [114]2 years ago
7 0

The following java code will be written for the prescribed

<u>Explanation:</u>

import java.util.*;

class UserName{

  ArrayList<String> possibleNames;

  UserName(String firstName, String lastName){

      if(this.isValidName(firstName) && this.isValidName(lastName)){

          possibleNames = new ArrayList<String>();

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

              possibleNames.add(lastName+firstName.substring(0,i));

          }  

      }else{

          System.out.println("firstName and lastName must contain letters only.");

      }

  }

  public boolean isUsed(String name, String[] arr){

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

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

              return true;

      }

      return false;

  }

  public void setAvailableUserNames(String[] usedNames){

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

      names = this.possibleNames.toArray(names);

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

          if(isUsed(usedNames[i],names)){

              int index = this.possibleNames.indexOf(usedNames[i]);

              this.possibleNames.remove(index);

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

              names = this.possibleNames.toArray(names);

          }

      }

  }

  public boolean isValidName(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 person1 = new UserName("john","smith");

      System.out.println(person1.possibleNames);

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

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

      System.out.println("possibleNames before removing: "+person2.possibleNames);

      person2.setAvailableUserNames(used);

      System.out.println("possibleNames after removing: "+person2.possibleNames);

  }

}

You might be interested in
A(n) ________ system collects data from various key business processes and stores the data in a single comprehensive data reposi
Anni [7]
Management information
4 0
2 years ago
What is ODBC? How is it related to SQL/CLI? 10.2. What is JDBC? Is it an example of embedded SQL or of using function calls? 10.
tamaranim1 [39]

Answer:hhhhhhhhh

Explanation:

5 0
2 years ago
Effective character encoding requires:
lidiya [134]

To answer your question the answer would be B compatible browsers

4 0
2 years ago
What is the name of the item that supplies the exact or near exact voltage at the required wattage to all of the circuitry insid
gizmo_the_mogwai [7]

Answer:

It's the <u><em>power supply</em></u>

Explanation:

The power supply is what essentially enables the computer to operate. It is able to do that by converting the incoming alternating current (AC) to direct current (DC) at the correct wattage rating that is required by the computer to function. The power supply is a metal box that is generally placed in the corner of the case.

4 0
2 years ago
Liza is making a presentation on the sales revenue of her surfboard company’s most popular surfboard models. She wants to emphas
Kazeer [188]
Answer:  
Liza is making a presentation on the sales revenue of her surfboard company’s most popular surfboard models. She wants to emphasize the model names as they appear one by one on the presentation slide. She also wants to depict the sales data for each model. "Goal seek" options can she use to achieve these goals.
6 0
2 years ago
Read 2 more answers
Other questions:
  • A form that dedicates a page for each item retrieved for a case; it allows investigators to add more detail about exactly what w
    10·1 answer
  • In response to a recent outbreak of computer viruses, Babbage Industries, a large technology company, installs computer virus pr
    7·2 answers
  • You are given an array x of string elements along with an int variable n that contains the number of elements in the array. You
    11·1 answer
  • Use the AND function with appropriate arguments in cell H11 to determine if there is a force out at third base. There is a force
    14·1 answer
  • Frequent menu users can become annoyed if they must make several menu selections to complete a simple task. Suggest two ways you
    10·1 answer
  • Write measurable performance objectives.Suppose that a trainer has identified as a generalgoal for a training module,"Able to fo
    13·1 answer
  • This program will output a right triangle based on user specified height triangle_height and symbol triangle_char. (1) The given
    9·1 answer
  • Disk scheduling algorithms in operating systems consider only seek distances, because Select one: a. modern disks do not disclos
    13·1 answer
  • Write a split check function that returns the amount that each diner must pay to cover the cost of the meal The function has 4 p
    14·1 answer
  • A file concordance tracks the unique words in a file and their frequencies. Write a program that displays a concordance for a fi
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!