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
my headphones have a mic and the mic and headset don't work at the same time what do i do to make them work together
JulsSmile [24]
Return them they are probably defective or turn ur media volume all the way down.
6 0
1 year ago
Read 2 more answers
. Create a text file that contains your expenses for last month in the following categories: • Rent • Gas • Food • Clothing • Ca
Whitepunk [10]

Answer:

  1. from matplotlib import pyplot as plt
  2. with open("text.txt") as file:
  3.    data = file.readlines()
  4.    category = []
  5.    amount = []
  6.    for row in data:
  7.        values = row.split(" ")
  8.        category.append(values[0])
  9.        amount.append(float(values[1]))
  10.    
  11. figure = plt.figure()
  12. ax = figure.add_axes([0,0,1,1])
  13. ax.axis('equal')
  14. ax.pie(amount, labels = category, autopct='%1.2f%%')
  15. plt.show()

Explanation:

Firstly, we need to import matplotlib library (Line 1).

Next, open a file stream and use readlines method to read the data from the text file (Line 4). Presume the data read from the text files are as follows:

Rent 450

Gas 150

Food 500

Clothing 120

Car 600

Create two lists, category and amount (Line 5-6). Use a for loop to traverse through the read data and use split method to break each row of data into two individual items. The first item is added to category list whereas the second item is added to amount list (Line 7 - 10).

Next, create a plot figure and then add the axes (Line 12 - 13). We can use the pie method to generate a pie chart (Line 15) by setting the amount list as first argument and category list as value of labels attributes. The output pie chart can be found in the attachment.

7 0
2 years ago
Clara writes online articles based on world religions. Her articles have references to dates. Which HTML element will help her d
brilliants [131]

Answer:

Available Options are :

A <b>

B <l>

C <body>

D <small>

Ans : A <b>

Explanation:

Normally AD and BC are written in bold letters.

for example : The terms anno Domini (AD) and before Christ (BC).

Within available option the best option to choose is <b>

The <body> element used to define the document body.

The <small> tag used to defines smaller text

But, the best option to choose is in case if they are using the HTML5  then html <time> element will be used to display BC date and AD dates.

for ex : <time datetime="-314-07-01"

calendar="Ancient Roman">1 July 314 BC</time>

3 0
1 year ago
An e-commerce client is moving from on-premise, legacy systems to a cloud-based platform. During the transition, the client is a
Talja [164]

The way in which this client is benefiting from switching to a cloud-based enterprise platform is in terms of<em><u> efficiency.</u></em>

An enterprise platform is a base upon which companies can<u> build on the technology they have</u>. Some of the many benefits of this include:

  • <em>Efficiency </em>
  • Simplicity
  • Expandability

and many more. A cloud-based enterprise platform allows a company to keep up to modern-day standards and stay competitive.

A cloud-based enterprise platform allows all of the users to access the data remotely, making work much more simple and removing the space limitations of on-site legacy systems, which allows the client to expand and hire new workers.

One of the ways in which this client is benefiting from switching to a <em>cloud-based enterprise platform</em> is in terms of efficiency. By removing the on-site model of work, this client will allow her workers to access the database and interchange information which other sectors all from a single server, <u>increasing efficiency greatly.</u>

To learn more visit:

brainly.com/question/24053883?referrer=searchResults

4 0
1 year ago
Which of the following corresponds to the computer interface technology that uses icon, etc?
Aleksandr [31]

Answer:

D) GUI

Explanation:

GUI an acronym for Graphical user interface, is a type of user interface where a user interacts with a computer or an electronic device through the use of graphics. These graphics include icons, images, navigation bars etc.

GUIs use a combination of technologies and devices to create a layout that users can interact with and perform tasks on. This makes it easier for users who do have basic computer skills to utilize.

The most common combination of these elements is the windows, icons, menus and pointer paradigm (WIMP) . GUIs are used in mobile devices, gaming devices, smartphones, MP3 players etc.

6 0
1 year ago
Other questions:
  • 7. Test Average and Grade Write a program that asks the user to enter five test scores. The program should display a letter grad
    15·1 answer
  • 1.2.2: Output variable value. Jump to level 1 Write a statement that outputs variable userAge. End with a newline. 1 2 3 4 5 6 7
    12·1 answer
  • What is the value of x after each of the following statements is encountered in a computer program, if x=1 before the statement
    9·1 answer
  • The process of __________ encourages members to accept responsibility for the outcomes of a group and for changing the style in
    8·1 answer
  • Write a program that generates 1,000 random integers between 0 and 9 and displays the count for each number. (Hint: Use a list o
    12·1 answer
  • array of String objects, words, has been properly declared and initialized. Each element of words contains a String consisting o
    11·1 answer
  • Write a program to read-in a sequence of integers from the keyboard using scanf(). Your program will determine (a) the largest i
    8·1 answer
  • What is the average number of nodes accessed in search for a particular element in an unordered list? In an ordered list? In an
    6·1 answer
  • You would use the _______ conditional formatting options when analyzing a worksheet in which you want to highlight the highest o
    13·1 answer
  • 2. BIOS is contained in ROM and not in RAM. Can you guess why?​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!