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
2.
Masja [62]

Answer:

is this a question or not?

6 0
3 years ago
Which is an example of artificial intelligence in computers? A. multimedia software B. encryption software C. voice recognition
andrezito [222]

Answer:

its option b encryption software

Explanation:

Artificial intelligence (AI) is intelligence demonstrated by machines, unlike the natural intelligence displayed by humans and animals, which involves consciousness and emotionality. The distinction between the former and the latter categories is often revealed by the acronym chosen. 'Strong' AI is usually labelled as AGI (Artificial General Intelligence) while attempts to emulate 'natural' intelligence have been called ABI (Artificial Biological Intelligence). Leading AI textbooks define the field as the study of "intelligent agents": any device that perceives its environment and takes actions that maximize its chance of successfully achieving its goals.[3] Colloquially, the term "artificial intelligence" is often used to describe machines (or computers) that mimic "cognitive" functions that humans associate with the human mind, such as "learning" and "problem solving".

3 0
2 years ago
How are network computers different from traditional personal computers? describe some usage scenarios in which it is advantageo
Elanso [62]
A network computer depend on on a centralized computer for most of its services. It can consequently have a minimal operating system while a personal computer on the other hand has to be proficient of on condition that all of the required functionality in a detached manner without depending on a centralized manner. Scenarios where administrative costs are high and where sharing leads to more efficient use of resources are exactly those settings where network computers are preferred.
8 0
3 years ago
Using the world_x database you installed in Module 1, list the countries and the capitals of each country. Modify your query to
Rainbow [258]

Answer:

SELECT country.Name, city.Name

FROM country

JOIN countrylanguage ON country.Code = countrylanguage.CountryCode

JOIN city ON country.Capital = city.ID

WHERE countrylanguage.Language = 'English'

AND countrylanguage.Percentage < 30;

Explanation:

SELECT is used to query the database and get back the specified fields.

City.Name is an attribute of city table.

country.Name is an attribute of country table.

FROM is used to query the database and get back the preferred information by specifying the table name.

country , countrylanguage and city are the table names.

country and countrylanguage are joined based ON country.Code = countrylanguage.CountryCode

countrylanguage and city are joined based ON country.Capital = city.ID

WHERE is used to specify a condition based on which the data is to be retrieved. The conditions are as follows:

countrylanguage.Language = 'English'

countrylanguage.Percentage < 30;

5 0
3 years ago
Jessie will make and sell the trending Baked California Maki. Her Peso mark up is 5.00. Selling price PHP 15.000. How much will
Levart [38]

Answer:

50%

Explanation:

The markup is the difference between the selling price and the cost price. If the mark up is greater than zero, it means there is a profit, if the markup is less than 0, it means there is a loss and if the markup is equal to 0, it means there is breakeven.

Percentage markup = (markup/cost price) * 100%

Selling price - cost price = markup

15 - cost price = 5

cost price = 10

Percentage markup = (markup/cost price) * 100% = (5/10) * 100% = 50%

7 0
3 years ago
Other questions:
  • As yall know its spoopy season. This means spoopy music! I am having a live stream on the Spoon app under the username teendrago
    11·1 answer
  • Convert each of the following for loops into an equivalent while loop. (You might need to rename some variables for the code to
    10·1 answer
  • Explain in a few sentences the difference between analytical papers and argumentative papers.
    8·2 answers
  • Write a function stats that takes an array and the number of elements in the array. Then, it computes and prints the minimum val
    8·1 answer
  • The most useful index fossils are of organisms that are still alive today.
    11·2 answers
  • Javier develops sophisticated fashion websites. He has been asked by the owner of a leading fashion brand to create web content
    13·1 answer
  • Hi need help on this <br> what is cyberspace
    14·1 answer
  • If I was to sort the months of the year in ASCENDING order alphabetically, which
    11·1 answer
  • Elizabeth works for a local restaurant at the end of her shift she read she’s required to write in the time that she arrived in
    14·1 answer
  • We have studied machine cycle in class. Suppose that each of the four modules of machine cycle is taking 2 seconds. If there are
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!