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
s2008m [1.1K]
3 years ago
10

SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classes listed in the Java Quick R

eference have been imported where appropriate. Unless otherwise noted in the question, assume that parameters in method calls are not null and that methods are called only when their preconditions are satisfied. In writing solutions for each question, you may use any of the accessible methods that are listed in classes defined in that question. Writing significant amounts of code that can be replaced by a call to one of these methods will not receive full credit. A mathematical sequence is an ordered list of numbers. This question involves a sequence called a hailstone sequence. Ifnis the value of a term in the sequence, then the following rules are used to find the next term, if one exists. If n is 1, the sequence terminates. If n is even, then the next term is n2. If n is odd, then the next term is 3n 1. For this question, assume that when the rules are applied, the sequence will eventually terminate with the termn

Computers and Technology
1 answer:
Ne4ueva [31]3 years ago
5 0

Answer:

Check the explanation

Explanation:

CODE:-

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);

  }

}

Kindly check the attached image below for the code output.

You might be interested in
How does limiting a company's scope benefit the company? A. It encourages the company to use division of labor. B. It makes it e
Luda [366]

Answer

It makes it easier to produce a high quality product.

Explanation

Project scope is the part of project planning that involves determining and documenting a list of specific project goals, deliverable, tasks, costs and deadlines. in Project management it  involves the planning and organization of a company's resources to complete a specific task, event, or action and is usually a one-time event. It is an activity that is engaged in for the primary purpose of making a profit. These activities includes things like  production, operations, marketing, and administration

6 0
3 years ago
Read 2 more answers
All slides in a presentation must use the same transition. True or False?
krek1111 [17]
False. you can make different slides have different transitions
7 0
3 years ago
Read 2 more answers
Google is an example of a(n):
Andre45 [30]
Well i see your X so i would say you were correct it is a search engine.
7 0
3 years ago
In which view of PowerPoint is the Annotation tools menu available?
lara31 [8.8K]

Answer:

2.

Explanation:

Annotating in PowerPoint is the create notes while delivering a PowerPoint presentation. This could be done in two ways.

First, right click with the mouse and select 'pointer options'. Then you can choose either pen or highlighter to circle certain word or highlight any line.

The second way of creating annotation is by going to View→Normal→Notes.

After you select 'notes', a pane will appear at the bottom of your presentation.

So, the correct answer that annotation tools menu is available in Normal. Thus option 2 is correct.

7 0
2 years ago
Read 2 more answers
What is the decimal equivalent of 11BA?
allsm [11]

Answer:

To convert hexadecimal number 11BA to decimal, follow these two steps:

Start from one's place in 11BA : multiply ones place with 16^0, tens place with 16^1, hundreds place with 16^2 and so on from right to left

Add all the product we got from step 1 to get the decimal equivalent of 11BA.

Using the above steps, here is the work involved in the solution for converting 11BA to decimal number (Don't forget that we start from ones place to so on...)

Decimal equivalent of "A" = (A) 10 × 16^0 = 10

Decimal equivalent of "B" = (B) 11 × 16^1 = 176

Decimal equivalent of "1" = 1 × 16^2 = 256

Decimal equivalent of "1" = 1 × 16^3 = 4096

Decimal equivalent of "11BA" = 409625617610

11BA = 4538

Here is the final answer, The hexadecimal number 11BA converted to decimal is therefore equal to:

4538

4 0
2 years ago
Other questions:
  • How to tell if screen or screen protector is cracked?
    5·2 answers
  • why is it important to use a general search engine, like GOOGLE, to look up the name of the organization, institution, agency or
    7·1 answer
  • What were the goals of the “paperless society” ideal?
    14·2 answers
  • There is no way to see how another project in Scratch was made.<br><br> True<br> False
    11·1 answer
  • How will using ascending order on a field that contains dates sort a list?
    12·2 answers
  • One common method of converting symbols into binary digits for computer processing is called ASCII​ (American Standard Code of I
    5·1 answer
  • how do I delete my brainly account, my child signed up for it and nothing has been paid but I do not want the account to exist a
    7·2 answers
  • The table button is present in the ……… tab.​
    14·2 answers
  • If html is used to specify the content of the webpage, then what do you use css for?.
    12·1 answer
  • How many pages is 1500 words double spaced 12 font?.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!