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]
2 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]2 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
Access time is:________.
worty [1.4K]

Answer:

B) the time it takes for the required sector to position itself under the read/write head.

Explanation:

In Computer science, Access time is the time it takes for the required sector to position itself under the read/write head. It is usually measured in milliseconds.

It is the speed of the storage device.

5 0
3 years ago
The process of capturing moving images on film or a digital storage device is called?
galben [10]

Answer:

Cinematography

Explanation:

Cinematography is the blend of art and science and it deals with the recording of moving images on film or a digital storage device.

While making a movie some example of cinematography are the conclusions reached about lighting, camera filters, lenses etc.

6 0
3 years ago
Which of the following is not a valid SQL command? (Points : 2) UPDATE acctmanager SET amedate = SYSDATE WHERE amid = 'J500';
Volgvan

Answer:

UPDATE acctmanager WHERE amid = 'J500';

Explanation:

The statement written above is not valid SQL statement because there is no SET after UPDATE. Update is always used with SET.If you are updating something then you need to specify the value with which that value should be replaced.

UPDATE acctmanager SET amname = UPPER(amname);

This statement does not contains WHERE clause but it will run all the values of amname column will get updated in the table acctmanager.

6 0
2 years ago
while investigating the settings on your SOHO router, you find two IP address reported on the devices's routing table, which is
DochEvi [55]

Answer:

From the two IP addresses, 192.168.2.1 can be listed as the default gateway in local network devices.

The reason is that we are allocated with the ranges that are reserved for the local networks by RFC 1918.

These ranges are given as follows:

  • For (10/8 prefix)  

                            10.0.0.0 - 10.255.255.255

  • (172.16/12 prefix)

                            172.16.0.0 - 172.31.255.255

  • (192.168/16 prefix)

                            192.168.0.0 - 192.168.255.255

Moreover the default gateway for a device can also be known by the commands ipconfig or  ipconfig/all on the command prompt.

<h3>I hope it will help you!</h3>
7 0
2 years ago
Please name the OOP term that allows children classes to have methods with the same names as methods in their parents.
RSB [31]

Answer:

Inheritance

Explanation:

3 0
3 years ago
Other questions:
  • Why is it important to have regular maintenance and care of your office equipment?
    5·1 answer
  • Data administration is a special organizational function that manages the policies and procedures through which data can be mana
    9·1 answer
  • Olivia creates a personal budget. She enters her current savings account balance in cell D3. In cell A3, she calculates her inco
    8·1 answer
  • Suppose company A wants to develop a program that duplicates the functionality of a programm by company B. Describe how company
    8·1 answer
  • Can someone help me, please
    7·1 answer
  • File-sharing programs such as Napster, Kazaa, and iMesh make it possible for individuals to exchange music files over the Intern
    7·1 answer
  • The natural language convention used to represent ip addresses is called the:
    15·1 answer
  • highlight the possible risks and problems that should be address during the implementation of information system process
    5·1 answer
  • Who elso does their online school in their bed cause i do
    7·2 answers
  • 72. In Object Oriented Programming, a class_____ starts
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!