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
AnnyKZ [126]
3 years ago
9

Write a method that returns a version of the given array where all the 10's have been removed. The remaining elements should shi

ft left towards the start of the array as needed, and the empty spaces at the end of the array should be set to 0.
Ex: {1, 10, 10, 2} yields {1, 2, 0, 0}. You may modify and return the given array or make a new array.

Code:

public class RemoveTen {
public static void main(String[] args) {
int[] nums = {1, 10, 10, 2};
int[] result = removeTen(nums);
for(int i = 0; i < result.length; i++)
System.out.print(result[i] + " ");
}

public static int[] removeTen(int[] nums) {
/*FIXME Complete the implementation of the removeTen method*/
}
}
Computers and Technology
1 answer:
Harlamova29_29 [7]3 years ago
8 0

Answer:

The removeTens method is as follows

public static int[] removeTen(int[] nums) {

int [] arr = nums;

   int index = 0;

   while(index < arr.length && arr[index] != 10){

       index++;

   for(int j = index + 1; j < arr.length; j++) {

       if(arr[j] != 10) {

           arr[index] = arr[j];

           arr[j] = 10;

           index++;        }    }

   for( ; index < arr.length; index++){

       arr[index] = 0;}}

   return arr;

}

Explanation:

This defines the removeTens method; it receives array nums as its parameter

public static int[] removeTen(int[] nums) {

This creates and initializes a new array

int [] arr = nums;

This initializes index to 0

   int index = 0;

The following is repeated when array element is not 10 and if array index is still valid

   while(index < arr.length && arr[index] != 10){

This increments the index by 1

       index++;

This iterates through the array

   for(int j = index + 1; j < arr.length; j++) {

This checks if array element is not 10

       if(arr[j] != 10) {

If yes:

           arr[index] = arr[j];

The current array element is set to 10

           arr[j] = 10;

The index is incremented by 1        

  index++;        }    }

This iterates through the array again and move 0s to the back

   for( ; index < arr.length; index++){

       arr[index] = 0;}}

This returns the new array

  return arr;

}

You might be interested in
What technique involves graphical methods and nontechnical language that represent the system at various stages of development a
Mnenie [13.5K]

Answer:

The answer to this question this "modeling".

Explanation:

In this question, the answer is modeling because in system design we use System Analysis and Design(SAD). It is the most important subject in any software design like a mobile application, website, web pages, etc. In this subject, there is an important topic that is SDLC. The term SDLC stands for systems development life cycle or it is also known as the software development life cycle. It is a conceptual modeling used in project management that describes the stages involves the information for system development project. It maintenance the complete application. SDLC applied to technical and non-technical systems. In the SDLC many phases can be given as:

Requirement gathering and analysis:

In this phase, all the relevant information is collected from the customer to develop a product as their expectation.

Design:

In the design phase, the requirement gather by the software requirements specification (SRS) in a document that is used for software architecture.

Implementation or coding:

After completing the design phase we implement/coding in that section like User input validation, admin work, payment management, etc.

Testing:

In this section, we test all the things in software before hand over to the customer.

Deployment:

In this section after completing the testing successfully. it goes to the deployment section in this section production environment or User Acceptance testing is done depending on the customer expectation.

Maintenance:

In the maintenance section when the product is hand over customer and in future if any issue comes up and needs to be fixed or there is any Up-gradation is needed So it is done by the developers.

In computer science, any development is done on modules. So the answer to this question is modeling.

3 0
3 years ago
Which of these is a major mobile game developer?
Amiraneli [1.4K]

Answer:

Zynga

Explanation:

Zynga is a leading developer of the world’s most popular social games that are played by millions of people around the world each day.

3 0
3 years ago
A file with a com extension is most likely to be a(n) ___ file.
olasank [31]
I think that the answer is: A executable
4 0
3 years ago
Read 2 more answers
You are assigned by your teacher to perform the assembly of all the parts of the computer in preparation for the hands on activi
Alexus [3.1K]

Answer:

answer it yourself or ask your teacker

Explanation:

7 0
2 years ago
____ policy establishes criteria for classifying and securing the organization's information in a manner appropriate to its leve
pav-90 [236]

Answer:

Correct Answer is (d) Information sensitivity policy

Explanation:

Information sensitivity policy establishes the criteria for classifying and securing the organization's information in a manner that is appropriate to its level of security.

However, other options are incorrect. Server security can be established only on servers and on information/data that is in the server from unauthorized access. While VPN security is used for protecting network and encryption is used to encrypt data from illegal access.

However, only information sensitivity policy is used for classifying and securing organization information to the outside world.

The intention of information sensitivity policy:

The intention of using any information sensitivity policy is to help the employee to determine what information can be disclosed to non-employee, as well as the relative sensitivity of the information that should not be disclosed outside of the company without proper permission or authorization from supreme leadership of an organization.

7 0
3 years ago
Other questions:
  • External hard disks use different technology than internal hard disks. ture or false
    6·1 answer
  • Sarah, a computer user, tells James, a computer technician, that the network she is connected to is running too slowly. Which of
    5·1 answer
  • Jeremy wishes to create a site map for his website. What tag will surround the URL of his home page? A. B. C. D.
    8·1 answer
  • What term is defined as private data placed in a packet with a header containing routing information that allows the data to tra
    13·1 answer
  • Explain the importance of mobile computing in communication​
    5·1 answer
  • As a general rule, what is the size of a brochure?
    11·1 answer
  • What is the term for the era created by the digital revolution?<br>​
    13·1 answer
  • What are some good digital habits?
    5·2 answers
  • Busco a talcotalco38
    14·2 answers
  • What were the names of Henry VIII's six wives?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!