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
Nikitich [7]
3 years ago
6

Create a static method that: - is called appendPosSum - returns an ArrayList - takes one parameter: an ArrayList of Integers Thi

s method should: - Create a new ArrayList of Integers - Add only the positive Integers to the new ArrayList - Sum the positive Integers in the new ArrayList and add the Sum as the last element For example, if the incoming ArrayList contains the Integers (4,-6,3,-8,0,4,3), the ArrayList that gets returned should be (4,3,4,3,14), with 14 being the sum of (4,3,4,3). The original ArrayList should remain unchanged.
Computers and Technology
1 answer:
Flura [38]3 years ago
3 0

Answer:

The method in Java is as follows:

public static ArrayList<Integer> appendPosSum(ArrayList<Integer> nums) {

   int sum = 0;

   ArrayList<Integer> newArr = new ArrayList<>();

   for(int num : nums) {

       if(num>0){

           sum+=num;

           newArr.add(num);        }    }

   newArr.add(sum);

   return newArr;

 }

Explanation:

This defines the method; it receives an integer arraylist as its parameter; nums

public static ArrayList<Integer> appendPosSum(ArrayList<Integer> nums) {

This initializes sum to 0

   int sum = 0;

This declares a new integer arraylist; newArr

   ArrayList<Integer> newArr = new ArrayList<>();

This iterates through nums

   for(int num : nums) {

If current element is greater than 0

       if(num>0){

This sum is taken

           sum+=num;

And the element is added to newArr

           newArr.add(num);        }    }

At the end of the iteration; this adds the calculated sum to newArr  

newArr.add(sum);

This returns newArr

   return newArr;

 }

You might be interested in
True or False
anastassius [24]

I used this from a other.

False

Software is the collection of large program or instruction of codes, which is used to perform some task. It is of two types of system software and application software.

The system software is used as a container for the application software and it is used to handle all other software it is used to operate the system.

Application software is used to perform any operation. This type of software can be used by the user if it is installed on the local machine on any system software

The operating system is also the part of the system software because it is used to operate the system and it is also the soul of the computer system which is also the function of the system software but the above question states that the operating system is not the part of the system software which is not correct. Hence false is the correct answer to the above question.

5 0
3 years ago
Which can be used to create a poll on a web page? <br>CSS<br>HTML <br>JavaScript <br>Text editor​
NeX [460]

Answer:

HTML can be used to create a poll on a web page.

4 0
2 years ago
You would like to help guide your company in choosing between valuing privacy and increasing the company's bottom line. What is
Ainat [17]

In the above case, the option that will help to guide your company in choosing between valuing privacy is a set of internal principles.

<h3>What are internal control principles?</h3>

The principles of internal control are known to be  needed in the management to set methods in place to make sure that company assets are kept.

Therefore, In the above case, the option that will help to guide your company in choosing between valuing privacy is a set of internal principles.

Learn more about internal principles from

brainly.com/question/27015769

#SPJ1

6 0
2 years ago
Ano ang maikling kwento??
marishachu [46]

Answer with Explanation:

Ang "maikling kuwento" ay isang uri ng<em> kathang-isip</em> na may pagkapareho sa nobela. Ito'y may buong tema ngunit mas maikli kaysa sa nobela at mas madali rin itong matapos basahin. Hango ito sa mga tunay na pangyayari sa buhay ng tao. Binubuo ito ng limang elemento: <em>tauhan, tagpuan, hidwaan, tema at plot. </em>Ito'y may balak na pukawin ang damdamin ng nagbabasa ayon sa kalagayan ng mga tauhan sa kuwento at ito'y nag bibigay ng mabuting aral.

Si <em>Edgar Allan Poe</em> ang tinaguriang<em> "Ama ng Maikling Kuwento." </em>

3 0
3 years ago
Law enforcement has contacted a corporation's legal counsel because correlated data from a breach shows the organization as the
Art [367]

Answer:

A is the correct answer.

Explanation:

Perform security awareness training about incident communication.

6 0
3 years ago
Other questions:
  • It will gain you more knowledge, intensify your soft skills, strong work ethics and grow your network. What is it?​
    12·2 answers
  • list the six external parts or "peripherals" of a computer system and identify which are output and which are input devices.
    15·1 answer
  • What are the four types of technical drawing?​
    9·1 answer
  • Random number between 0 and 5 (inclusive)
    10·2 answers
  • T F Changes to a function parameter always affect the original argument as well.
    15·1 answer
  • After reading his e-mail messages, Orlando became very frustrated. Many of the messages he received did not conform to netiquett
    6·1 answer
  • Why is it important to prepare the farm resources before you start working? explain​
    14·1 answer
  • Which native windows application allows you to access basic pc settings and controls such as system information, controlling use
    7·1 answer
  • What are 2 ways to send a message to your client when signed in as an accountant user?.
    9·1 answer
  • in a small town, there are two providers of broadband internet access: a cable company and the phone company. the internet acces
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!