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
Mobile devices have their own OSs, tailored to their handheld needs, which means they are not immune to what?
NikAS [45]

Answer:

Malware

Explanation:

Malware is used in many types of software included handheld OS's

6 0
2 years ago
The next four octal numbers after 36 is:________.
Papessa [141]

Answer: b. 37, 40, 41, 42

Explanation:

The next four octal numbers after 36 is 37, 40, 41, 42.

The octal numeral system, which is also referred to as "oct" for short, is simply base-8 number system.

It is a number system whereby only digits from 0 to 7 are used and there are no letters or numbers that are above 8 that are used.

In this case, after 36, the next number will be 37 after which we go to 40 as we can't write 38 in the octal system. Therefore, the next four octal numbers after 36 is 37, 40, 41, 42.

7 0
3 years ago
Many works by Mark Twain were published before 1923. In addition, there are other works that were discovered after his death and
Sauron [17]
I think is the last one
4 0
3 years ago
first 2 questions are true or false the last question is multiple choice. 7th grade work. plz only answer if u know.
pshichka [43]

#4 is true

We use pseudocode to help us understand code.

#5 is false

Strings are surrounded by quotes, integers are not.

#6 is 100.

Integers are numbers with no decimal places.

3 0
3 years ago
An internal _____ refers to a specific representation of an internal model, using the database constructs supported by the chose
boyakko [2]

Answer:

An internal schema                                                            

Explanation:

  • The internal schema refers to the physical storage structure of database.
  • It refers to the lowest level of abstraction.
  • This is also called physical schema.
  • It contains multiple instances of multiple internal records.
  • It provides information about the representation of the whole database that what data is stored in DB and in what form e.g the data is stored in the records form on the disk.
  • This schema gives detailed description of internal model which involves storage structure of the database, representation and classification of stored data. This format of data is only understandable by the Database management system.
7 0
3 years ago
Other questions:
  • Which term collectively describes hard disks, CDs, and flash drives?
    11·2 answers
  • Professional photography is a competitive job field. <br> true <br> false
    12·2 answers
  • What term best describes the way the dns name space is organized?
    9·1 answer
  • Which of these BEST describes an inference?
    11·2 answers
  • Question 1 :George, a user, is having trouble connecting to network resources, including shared folders on the local network and
    7·1 answer
  • What simple machine is most often used to lift the blinds on a window?
    8·2 answers
  • Find out the names of at least 20 programming languages and their developers.
    12·2 answers
  • Gn guys have an Amazing day!
    12·2 answers
  • Please describe the role of games in modern society!
    5·2 answers
  • Which option should you choose to change the background of your current slide?
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!