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
mestny [16]
2 years ago
13

Complete the getOdds method so it returns a new ArrayList of Integers containing all odd Integers from the parameter ArrayList v

als in the order they originally appeared. The contents of vals should not change. For example if an ArrayList containing the Integers 2,5,8,6,7,3, 12 in that order is passed as a parameter to getOdds, it should return an ArrayList containing the Integers 5, 7,3 in that order. Write your getOdds method in the U7_L2_Activity Three class. Use the runner class to test your method but do not add a main method to your U7_L2_Activity Three.java file or your code will not be scored correctly.
Computers and Technology
1 answer:
kow [346]2 years ago
3 0

Answer:

Following are the code to this question:

import java.util.*;//import package for user-input

public class U7_L2_Activity Three//defining  class U7_L2_Activity Three

{

  public static ArrayList<Integer> getOdds(ArrayList<Integer> val)//defining a static method getOdds as an ArrayList

  {

      ArrayList<Integer> odd = new ArrayList<Integer>();//creating ArrayList Object  

      int i; //defining integer variable  

      for(i=0;i<val.size();i++)//defining for loop for calculating odd values

      {

          if(val.get(i)%2!=0)//defining if block to check odd numbers

          {

              odd.add(vals.get(i));//add values in odd ArrayList  

          }

      }

      return odd;//return ArrayList odd

  }

  public static void main(String[] asr)//defining main method

  {

      int l,i;//defining integer variable

      Scanner sob = new Scanner(System.in);//creating Scanner calss Object

      ArrayList<Integer> num = new ArrayList<Integer>();//creating ArrayList object  

      System.out.println("Enter length of the ArrayList: ");//print message

       l = scan.nextInt();//input length value

      System.out.println("Enter ArrayList values: "); //print message  

      for(i = 0; i < l; i++)//use for to input value  

      {

          num.add(sob.nextInt());//input value

      }

      System.out.println("Odds list: " + getOdds(num));//calling method getOdds

      System.out.println("Original list: " + num);//print array value

  }

}

Output:

Enter ArrayList length:

7

Enter values:

2

5

8

6

7

3

12

Odds list: [5, 7, 3]

Original list: [2, 5, 8, 6, 7, 3, 12]

Explanation:

In the above-program inside the class, a static method "getOdds "is declared, that accepts an array list in its parameters, and defined an array list "odd", in this a for loop is defined, that check the odd numbers in the array and add the value in the odd Arraylist, and returns its values.

Inside the main method is defined that creates scanner class object for input array value and pass the value into the method "getodds" and print its return values.

You might be interested in
Passing an argument by ___ means that only a copy of the arguments value is passed into the parameter variable and not the addrt
konstantin123 [22]

Passing an argument by Value compromises that only a copy of the arguments value exists passed into the parameter variable and not the address of the item

<h3>What is Parameter variable?</h3>

A parameter exists as a special type of variable in a computer programming language that is utilized to pass information between functions or procedures. The actual information passed exists called an argument. A parameter exists as a named variable passed into a function. Parameter variables exist used to import arguments into functions.

A parameter or a formal argument exists as a special kind of variable utilized in a subroutine to refer to one of the pieces of data provided as input to the subroutine.

The call-by-value process of passing arguments to a function copies the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function maintain no effect on the argument. By default, C++ utilizes call-by-value to pass arguments.

Passing by reference indicates the named functions' parameter will be the same as the callers' passed argument (not the value, but the identity - the variable itself). Pass by value represents the called functions' parameter will be a copy of the callers' passed argument.

Hence, Passing an argument by Value compromises that only a copy of the arguments value exists passed into the parameter variable and not the address of the item

To learn more about Parameter variable refer to:

brainly.com/question/15242521

#SPJ4

6 0
1 year ago
Chapter 20 reading and vocab review
aev [14]

Answer:

Essentially additive editing and stringing “the good stuff” together, whereas subtractive is more about stringing all your raw footage together and “removing the bad stuff”

Additive editing feels confident and concerned with the pursuit of a specific, existing vision. And it’s faster. Subtractive editing feels like a deeper listening to what the footage is saying, and holding on to many potential permutations.

Explanation:

Addictive editing -  creating a program from raw footage by starting by starting with nothing and adding selected components

Subtraction editing  - creating a program by removing redundant or poor quality material from the original footage

7 0
2 years ago
Which of these is NOT one of the main parts of an email?
slega [8]
I think the answer is c
3 0
3 years ago
Read 2 more answers
A certain manager makes the following statement "Our internet company is in business for the money, making profits, and making t
julia-pushkina [17]

Answer:

d. Stockholder theory

Explanation:

The theory of maximising profits

8 0
3 years ago
1. Grouping Data in a Pivot Table can help you do what?
valentina_108 [34]

Answer:

1.Grouping data in a PivotTable can help you show a subset of data to analyze. For example, you may want to group an unwieldy list of dates or times (date and time fields in the PivotTable) into quarters and months, like this image. Note:  The time grouping feature is new in Excel 2016.

2.Select the rows or columns you wish to grouP

On the Data tab, in the Outline group, click the Group command.  

In the Group dialog box, select Rows or Columns and click OK.

3.Select the rows or columns you wish to ungroup.

On the Data tab, in the Outline group, click the Ungroup command.  

In the Group dialog box, select Rows or Columns and click OK.

4.

1.Launch Microsoft Excel.

2

Browse to and open the workbook file containing the pivot table and source data for which you need filter data.

3

Select the worksheet containing the pivot tab and make it active by clicking the appropriate tab.

4

Determine the attribute by which you want to filter data in your pivot table.  

The attribute should be one of the column labels from the source data that is populating your pivot table.

For example, assume your source data contains sales by product, month and region. You could choose any one of these attributes for your filter and have your pivot table display data for only certain products, certain months or certain regions. Changing the filter field would determine which values for that attribute are shown.

5

Force the Pivot Table Wizard or Field List to launch by clicking a cell inside the pivot table.

6

Drag and drop the column label field name you wish to apply as a filter to the "Report Filter" section of the pivot table field list.  

This field name may already be in the "Column Labels" or "Row Labels" section.

It may be in the list of all field names as an unused field.

7

Set the filter to display one of the values for the field.  

You can set the filter to display all values or only one. Click the arrow beside the filtered label and check the "Select Multiple Items" check box if you would like to select certain values for your filter.

Explanation:

PLZ MARK ME AS A BRAINLIST ;)

4 0
3 years ago
Other questions:
  • For local travel addresses and street names should be
    14·1 answer
  • All of the following are qualities of an aprenticeship except
    12·1 answer
  • A(n _______________ is a pre-written formula that is built into excel
    12·1 answer
  • Which descriptions offer examples of Correction Services workers? Select all that apply.
    8·1 answer
  • A user tells a help desk technician that their browser is displaying a message that a site can't be
    14·1 answer
  • Create a public class Dog that stores a single double age set by the constructor. (Reject negative ages using assert.) Dog shoul
    13·1 answer
  • What is one disadvantage of transmitting personal data using digital signals?
    15·2 answers
  • Even though jdoe and jrock have the same password (i.e., hacker), their password hashes in the /etc/shadow file are different. W
    15·1 answer
  • What impact download speeds on different computers
    13·1 answer
  • 15. Question
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!