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
artcher [175]
2 years ago
12

Write a static method called split that takes an ArrayList of integer values as a parameter and that replaces each value in the

list with a pair of values, each half the original. If a number in the original list is odd, then the first number in the new pair should be one higher than the second so that the sum equals the original number. For example, if a variable called list stores this sequence of values:
Computers and Technology
1 answer:
lorasvet [3.4K]2 years ago
5 0

Answer:

The method is as follows:

public static void split(ArrayList<Integer> mylist) {

   System.out.print("Before Split: ");

   for (int elem = 0; elem < mylist.size(); elem++) { System.out.print(mylist.get(elem) + ", ");    }

   System.out.println();

   for (int elem = 0; elem < mylist.size(); elem+=2) {

       int val = mylist.get(elem);

       int right = val / 2;

       int left = right;

       if (val % 2 != 0) {            left++;        }

       mylist.add(elem, left);

       mylist.set(elem + 1, right);    }        

   System.out.print("After Split: ");

   for (int elem = 0; elem < mylist.size(); elem++) { System.out.print(mylist.get(elem) + ", ");    }

}

Explanation:

This declares the method

public static void split(ArrayList<Integer> mylist) {

This prints the arraylist before split

<em>    System.out.print("Before Split: "); </em>

<em>    for (int elem = 0; elem < mylist.size(); elem++) { System.out.print(mylist.get(elem) + ", ");    } </em>

<em>    System.out.println(); </em>

This iterates through the list

   for (int elem = 0; elem < mylist.size(); elem+=2) {

This gets the current list element

       int val = mylist.get(elem);

This gets the right and left element

<em>        int right = val / 2; </em>

<em>        int left = right; </em>

If the list element is odd, this increases the list element by 1

       if (val % 2 != 0) {            left++;        }

This adds the two numbers to the list

       mylist.add(elem, left);

       mylist.set(elem + 1, right);    }      

<em>This prints the arraylist after split</em><em> </em>

<em>    System.out.print("After Split: "); </em>

<em>    for (int elem = 0; elem < mylist.size(); elem++) { System.out.print(mylist.get(elem) + ", ");    } </em>

<em>}</em>

You might be interested in
"You are on a service call to fix a customer’s printer when she asks you to install a software package. The software is on a per
pickupchik [31]

Answer:

Ask her to get a genuine software

Explanation:

if i will install, it can cause the following problems:

1. Prated software makes your system Vulnerable to the security attacks because the activities of the software are not monitored by any organization and no one is responsible for anything bad happened to your system.

2. It may stop working anytime because there would not be maintenance patches available for it so that it can work properly.

3. It cannot be updated and may cause problems in core functionalities of it.

4.Serious legal actions can be taken against anyone using them because  economy has drastic decrease due ti use of it.

7 0
3 years ago
____allow(s) visually impaired users to access magnified content on the screen in relation to other parts of the screen.
Ksenya-84 [330]
I think the answer is Screen Magnifiers
5 0
3 years ago
The implementation stage of the SDLC is when the system is moved into operation where it can be used. What stage PRECEDES the im
antiseptic1488 [7]

The stage that precedes the implementation stage of SDLC is <u>testing</u> and it involves checking the functionality of the system.

System design involves the process of determining an overall system architecture, which typically comprises the following:

  • Hardware.
  • End users.
  • Physical processing components.
  • Software.
  • Communication channel.

Generally, there are seven (7) main stages in the systems development life cycle (SDLC) model and these include:

1. Planning.

2. Analysis.

3. Design.

4. Development.

5. Testing.

6. Implementation.

7. Maintenance.

From the above, we can deduce that the stage which precedes the implementation stage of SDLC is testing.

During the testing stage of SDLC, a quality assurance (QA) expert checks the system to determine whether or not it is functioning properly before it is deployed for operation, which is where the system can be used.

Read more: brainly.com/question/20813142

7 0
3 years ago
Explain how the number of jobs available to workers has been affected by the use of ICT in commerce and industry, using specific
blondinia [14]

Answer:

The main cause of lack of jobs is due to automation and the ability for computers to do everything faster, more efficiently and effectively.

Explanation:

A specific example - Data entry jobs are redundant from automation programs

- Economic Forum predicted a net increase of 58 million jobs for automation, so this accounts for losses but isn't case specific to data entry

6 0
2 years ago
HELP ME ASAP
ruslelena [56]

it is title page and give me a ❤

3 0
3 years ago
Other questions:
  • For your new sporting goods store, you originally planned to only sell Nike shoes. Therefore, you only had enough shoe displays
    11·2 answers
  • When configuring services, what linux directory typically contains server configuration files?
    8·1 answer
  • How many much memory is in one megabyte ?
    9·1 answer
  • Instagram
    9·1 answer
  • Recall the problem of finding the number of inversions. As in the text, we are given a sequence of n numbers a1, . . . , an, whi
    8·1 answer
  • When you _____ a scroll bar, a shortcut menu appears with commands related to the scroll bar
    10·1 answer
  • What does a computer need from people in order to solve problems effectively?
    9·1 answer
  • Write a program that first reads in the name of an input file and then reads the input file using the file.readlines() method. T
    7·1 answer
  • Help fast plzzzzzzzzzzzz ​
    10·2 answers
  • You are between flights at the airport and you want to check your email. Your wireless settings show two options:
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!