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]
4 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]4 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
HELP PLEASE!!!! If you are continually building, reviewing, correcting a model of your system, and incrementally adding to the s
Novosadov [1.4K]

Answer: evolutionary with high fidelity

Explanation:

You are trying to improve the model so that it is able to match any problem. This is evolutionary.

At the same time the model seems to be close to being finalised with all the improvements being made. It is past the design stage and so must be a high fidelity prototype.

6 0
3 years ago
What do you believe are the advantages of a clean install over an upgrade? What additional choices do you think are important to
Allushta [10]

Answer:

Upgrade refers to upgrading to a new version from old version

Clean Install: Removing old version completely and install from scratch

Explanation:

Let you want to upgrade windows server 2008 to windows server 2016.There are 2 options

1. you can directly migrate windows server 2008 to 2016 by keeping everything as it is , so all the data and applications on the system remains as it is and only OS will upgrade.

2. uninstall everything and clean install windows server 2016.Here all previous applications and data are erased

In the above case if all applications on the system are compatible with windows server 2016 from 2008 we can go for upgrade directly otherwise it is better to go with clean install as we need different version of application which is compatible with windows server 2016

3 0
3 years ago
Which of the following need NOT be completed separately if a worksheet is prepared?
Anika [276]
C because you already have you sheet prepared
3 0
4 years ago
1. It manages the computer's memory and processes, as well as all of its software and hardware.
8_murik_8 [283]

Answer:

B. Computer operating system

Explanation:

the operating system (or OS) manages all of the hardware and software in the computer, and allows hardware and software to communicate.

We can also figure this out by process of elimination: Application software is just a fancy way to say apps, Graphical User Interface (or GUI) are menus that allow a user to use the computer through a visual representation (what you interact with using your mouse), and microcomputer just means a small computer like a laptop or a phone.

6 0
3 years ago
what are some examples of security goals that you may have for an organization? check all that apply.
ExtremeBDS [4]

An examples of security goals that you may have for an organization is:  

  • To protect customer data against unauthorized access.

<h3>What is customer credentials about?</h3>

The goal of a firm in terms of security is to Safeguards or Defend customer credentials or details.

Therefore, An examples of security goals that you may have for an organization is:  

  • To protect customer data against unauthorized access.

Learn more about security goals from

brainly.com/question/14139033

#SPJ11

6 0
2 years ago
Other questions:
  • A software program that allows a programmer to type in code. modern versions usually make it easy to format the code on the scre
    13·1 answer
  • Discuss briefly four types of websites and the criteria you will use to evaluate the content of a website
    8·1 answer
  • . Write a C++ Code to get a multiline statement Str1 from a user with a ‘$’ as return character (Hint:
    6·1 answer
  • Consider a file/directory with the following info:
    14·1 answer
  • To generate a series of first ten counting number of algorithm​
    9·1 answer
  • Computers are used because they :
    9·2 answers
  • 1. Who is known as the father of a computer?​
    12·2 answers
  • Give two differences between ergonomic keyboard and standard keyboard?​
    9·1 answer
  • Where does blood travel when it leaves the right ventricle of the heart
    11·2 answers
  • Explain the relationship between one’s point of view and understanding spoken text
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!