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
Please read !!!
prisoha [69]
Don’t stress. You’re no failure if you believe in yourself. Have some faith. Don’t give up and live your life to the fullest. Take care and stay safe!! :)
3 0
3 years ago
How to be like Elon Musk who achieved more in his 46 years than we will ever achieve in ten lifetimes?
kvasek [131]

Answer:

You can just be yourself?

4 0
3 years ago
Linda is the education manager for a national coding service company. Once a month she holds a videoconference with all her codi
Andru [333]

Answer:

Option (D) i.e., synchronous is the correct option to the following question.

Explanation:

The following statement are the synchronous type of training because it is the type of training which is given to students or the persons for the purpose of knowledge in present time and the trainer or that person who give them information they can receive feedback and message at that time and all persons has permission to ask questions with them.

Option C is incorrect because in this type of training the interaction between the trainer and the receiver could not be established.

Option A is incorrect because the classroom-based training only for that person or the students who are available at that time at that place and in this video conferencing is not available.

8 0
3 years ago
PLEASE HELP I'M TAKING A QUIZ AND I HAVE 5 MINUTES LEFT
larisa [96]

Answer:

pp popo

Explanation:

6 0
3 years ago
Read 2 more answers
What is HTML ? <br>Give a small description about html
Genrish500 [490]
Hypertext Markup Language, a standardized system for tagging text files to achieve font, colour, graphic, and hyperlink effects on World Wide Web pages.
this information was taken from google
7 0
2 years ago
Read 2 more answers
Other questions:
  • Activity 1: Matched pairs or independent/separate samples? For each of the prompts below, decide whether the parameter of intere
    11·1 answer
  • Whenever I ask a question I loose points I just asked a question before and I had 56 points now I have 12 now I'll probably have
    14·1 answer
  • Reasons for the growth of decision-making systems include:
    13·1 answer
  • What is earning potential?
    10·1 answer
  • A student opens a recently purchased software package and begins reading the enclosed materials. What information might be inclu
    6·1 answer
  • Your source data is of 50 GB. You make a full backup. Next week, once again you perform a full backup, but this time 10 more GB
    10·1 answer
  • Which of these is a valid use of the Reply All feature?
    11·1 answer
  • Fill in the table below of the Interactive Word Wall. You are provided with the
    13·1 answer
  • There's a rising issue with bots sending links starting with 'bit'. These links are dangerous and harmful for any computer or de
    6·2 answers
  • Does technology shape society or does society shape technology?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!