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
mart [117]
4 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]4 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
Its an HTML5 anyone kwons
Aleksandr [31]

Answer:

1 will be stored in result

Explanation:

Given

The lines of code

Required

Determine the value stored in result

The value stored in result is determine by the condition (x<3 && y ==6)

In the first line, the value of x is 2 and the value of y is 6

So: x<3 is true because x = 2 and 2 is less than 3

y == 6 is also true because y = 6 and 6 is equal to 6

So, the condition (x<3 && y ==6) is true and true will be saved in variable result

Because result is a Boolean variable which can only take true or false value

1 represents true

0 represents false

<em>So, 1 will be stored in result</em>

7 0
3 years ago
Write a program that prompts the user to input two numbers, a numerator and a divisor. Your program should then divide the numer
fredd [130]

Answer:

#first section

a= float(input(" enter Numerator: " ))

b= float(input(" enter Divisor: "))

#second section

c = a//b

d = a%b

 

#third section

print(c, "is the quotient")

print(d, "is the remainder")

print ( c," remainder ",d)

Explanation:

In python (programming language) there are other ways to divide other than using the normal division "/".

we have floor division "// " and % modulo

<h3>floor division "//" gives you just the QUOTIENT </h3><h3>modulo gives you  the REMAINDER.</h3><h2></h2>

now the program is divided into 3 sessions to make it easy for you to understand.

The first session - This is the input session, it prompts you to in put two values respectively, one for the Numerator and one for the divisor.

The second session - this is where the calculation happens, we carry out a floor division first and then a modulo division.

The third session -  This is the Output session prints your answer to the screen, firstly it tells you which number is the quotient and which number is the remainder, after that it combines both the quotient and the remainder into one output

5 0
4 years ago
What is the financial aspect for a business as to what database software they will buy?
Masteriza [31]

Answer:  Database software is bought on basis of the processing, cost, requirement etc for any particular . According to the financial perspective the database  software should have the following characteristics:-

  • Database software that has most accurate and main feature according to the business requirement is selected for buying and the others with extra features are not considered as more feature cost more amount  which is not needed.
  • Database software which is still in progress to be built is pre-booked and money is invested on it because the price of the required software might increase after getting completed.
  • Scalable database software should be bought so that it can extend according to need at low cost.

 

8 0
4 years ago
A ______ is a computer that controls access to the hardware, software, and other resources on a network. mainframe server workst
kykrilka [37]
The answer is mainframe
4 0
3 years ago
The prefix kilo stands for which one of the following values? A. 100 or 102 B. 1000 or 103 C. 1,000,000 or 106 D. 10,000 or 104
Jobisdone [24]
It means multiplying or dividing by 10, 100, 1000, etc
3 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following self-contained APs are autonomous, or independent, because they are separate from other network devices a
    5·1 answer
  • Marge needs to collect network device configuration information and network statistics from devices on the network. She wants to
    14·1 answer
  • LITERALLY PLS ANYONE!!! 90 pointsss!
    7·2 answers
  • When is a wrecker considered to be an emergency vehicle?
    12·1 answer
  • True or False: It is illegal to park in a location that you block or create a hazard for other vehicles.
    11·2 answers
  • ______ allows a thread to run on only one processor.
    6·1 answer
  • The merge process involves which two types of files?
    5·1 answer
  • The technology dealing with robots is called
    6·1 answer
  • The conversion rate is the percentage of what? A. Customers who received cold calls B. Sales leads who reached the interest stag
    13·1 answer
  • ___ is the most important variable that is measured and controlled in a commercial hvac system.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!