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
Maru [420]
3 years ago
8

The following method is intended to remove all values from the ArrayList a that have the same value as val; however, this method

does not work correctly.public void removeValue(ArrayList a, int val) {int i;for (i = 0; i < a.size(); i++) {if (a.get(i) == val) {a.remove(i);}}}If the a contains 2 3 4 3 3 4 4 5 4 3 2 1 and val is equal to 4, then a should contain 2 3 3 3 5 3 2 1 after removeValue is invoked. What does a actually contain after removeValue is invoked? (2 points)1) 2 3 3 4 4 5 4 3 2 12) 2 3 3 3 4 5 3 2 13) 2 4 3 4 5 4 2 14) 2 3 3 3 5 3 2 15) 2 4 3 4 4 5 3 2 1
Computers and Technology
1 answer:
Alona [7]3 years ago
6 0

Answer:

ArrayList a contains [2, 3, 3, 3, 4, 5, 3, 2, 1]

Explanation:

Given

The removeValue method

Required

The content of ArrayList a, after the method is called

From the question, we understand that arraylist a is:

a= [2, 3, 4, 3, 3, 4, 4, 5, 4, 3, 2, 1]

val =4

The function fails when the value to be removed appear consecutively in the list.

4 appears in index 5 and 6 of the list. Only one of the 4's will be removed

So, the updated list will be: [2, 3, 3, 3, 4, 5, 3, 2, 1]

You might be interested in
write a command-line program which prompts the user for a series of decimal integer values separated by spaces. display each dec
zepelin [54]

A number expressed by 0s and 1s is referred to as a binary literal (binary digits). Integral types (byte, short, int, and long) can be expressed in Java using a binary number system.

The integral value might be prefixed with 0b or 0B to specify a binary literal. By constantly dividing the supplied number by 2 until we receive 0 as the quotient, we can convert a decimal number to a binary number in the simplest way possible. The binary value of the specified decimal number is then obtained by writing the remainders in reverse order. Any of the digits 0 through 9 can be found in a decimal integer literal. The octal integer literal, as opposed to the decimal integer literal, is used to interpret integer literals that start with the number 0.

Learn more about binary here-

brainly.com/question/19802955

#SPJ4

5 0
1 year ago
Software that helps run the computer's hardware devices and coordinates instructions between applications is called
Inessa [10]

The question above contains multiple choices;

<span>a.       </span>Application

<span>b.      </span>Recovery

<span>c.       </span>Backup

<span>d.      </span>System

The answer is d) System software.


The system software consists of the operating systems and utility programs which are usually preinstalled. The operating system controls how a PC system functions. Utility programs, on the other hand, perform general tasks for the computer like system maintenance and file compression.








7 0
4 years ago
Help me with this, please. Are vacuum cleaners, Cd players, and telephones considered computers? Do they store any data or proce
OleMash [197]

Answer:

search it up on google

Explanation:

5 0
4 years ago
Read 2 more answers
Expressing your needs to others is aggressive behavior.<br> True or False?
nasty-shy [4]
False. Expressing your needs to others is basically just saying what you need and what you want but you are not being aggressive unless you are hurting the person (physically or verbally) to get what you want. 
4 0
3 years ago
Read 2 more answers
For this assignment, you will use pointers to write a program that can be used to gather statistical data about the number of mo
salantis [7]

Answer:

Following are the program to the given question:

#include <iostream>//header file

#include <bits/stdc++.h>//header file

using namespace std;

int main()//main method

{

   int x,i,sum=0;//defining integer variable

   double average, median;//defining double variable

   cout<<"How many students were surveyed? ";//print message

   cin>>x;//input value

   int *a = new int[x]; //dynamically created array

   for(i = 0;i<x;i++)//defining for loop to input value in array

   {

       cout<<"Enter the number of movies seen by student number "<<i+1<<": ";//print message  

       cin>>a[i];//input value

   }

   for (int i = 0; i < x; i++)//defining loop for add value

       sum += a[i];   //use sum to add array value

   average = (double)sum/x;//defining average variable to calculate average

   cout<<"Average is "<<average<<endl;//print average value with message

   sort(a, a+x); //use sort method to sort array to find the median

   if (x % 2 != 0)//use if to check the even value

      median = (double)a[x/2];//calculating the median value

   else//esle block

       median = (double)(a[(x-1)/2] + a[x/2])/2.0;//calculating median value

   cout<<"Median is "<<median<<endl;//print median value with message

   int m_count=1 ,mode= a[0], c_count = 0;//defining integer variable

   for( i=1;i<x;i++)//defining for loop arrenge value

   {

       if(a[i]==a[i-1])//use if to check array value

       {

           c_count++;//increment c_count variable value

       }

       else//else block

       {

           if(c_count>m_count)//use if to check c_count greater than m_count

           {

               m_count = c_count;//holding value in m_count

               mode = a[i-1];//holding mode value

           }

           c_count = 1;//holding value integer value in c_count

       }

   }

   cout<<"Mode is "<<mode;//print mode value with message

   return 0;

}

Output:

Please find the attachment file.

Explanation:

  • Including header file.
  • Defining the main method.
  • Declaring integer and double type variables.
  • Declaring integer array.
  • Use the loop to the input value.
  • After input, the value uses double variable "average, the median" that uses the for loop and conditional statement to check the value and hold in its variable.
  • In the next step, another integer variable "m_count, mode, and c_count" is defined that uses the loop and conditional statement to check the median and mode value and hold its value into their variable.

4 0
3 years ago
Other questions:
  • Chris has received an email that was entirely written using capitalization. He needs to paste this text into another document bu
    13·2 answers
  • With the technology scaling and process improvement, do you think that existing CMOS will be able to exist in future?
    6·1 answer
  • DOES ANYONE KNOW HOW TO CHAGE THE IP ON A COMPUTER?
    8·1 answer
  • The ____________ is a wildcard character that is used to search for an unknown single character.
    6·1 answer
  • The ______ is the information center that drivers need to refer to when they're NOT scanning the road.
    14·1 answer
  • The degree to which a firewall can impose user access restrictions is known as which of the following?Security assurancePrivileg
    8·1 answer
  • Ancler Corporation wants to calculate how much their profits were in the first quarter of the year. They should use a
    6·2 answers
  • In cell K8, create a formula using the SUM function that calculates the total of the range D17:D20 and subtracts it from the val
    6·1 answer
  • which network component connects a device to transmission media and allows the device to send and receive messages?
    7·1 answer
  • 7+9 help me pleas i dont know help now
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!