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
_________ media must be downloaded in its entirety to the user's computer before it can be heard or seen
gladu [14]

Answer:

Downloadable

Explanation:

Cloud computing can be defined as a type of computing that requires shared computing resources such as cloud storage (data storage), servers, computer power, and software over the internet rather than local servers and hard drives.

Generally, cloud computing offers individuals and businesses a fast, effective and efficient way of providing services.

In Computer science, a downloadable media must first be downloaded in its entirety and saved to a user's computer before it can be played, heard or seen.

For example, for an end user to listen to a song hosted on a particular website, he or she must first of all download the song in its entirety and have saved on a computer system before it can be seen, played and listened to. Also, other downloadable media such as videos, animations, texts, etc., must be downloaded before they can be accessed or used by an end user.

4 0
3 years ago
After you divide the viewfinder appropriately you locate the subject? PLZ ANSWER MY TEST DO BY TONIGHT
Sloan [31]
The Answer is A: <span>along one of the division lines. </span>
4 0
3 years ago
What does gps stand for ?
frutty [35]
GPS stands for Global Positioning System
3 0
3 years ago
Read 2 more answers
A coffee shop is considering accepting orders and payments through their phone app and have decided to use public key encryption
Charra [1.4K]

Answer: Yes

Explanation:

Public key encryption is the encryption technique that is used for private keys and public keys for securing the system.Public key is used for encryption and private key is for decryption.Public keys can only open content of the system

  • According to the question, public key encryption is secure for coffee shop customer payment process as they are stored on digital certificates in long form for verifying digital signature and encrypting information.Its computation is difficult to crack through power computer access.  
  • Other options is incorrect as encryption is not a problem for payment procedures. Thus, the correct option is yes ,public key encryption is secure method for coffee shop customers .
8 0
3 years ago
Howie is a business analyst who is given access to the database of a product prior to its launch. He needs to understand the dat
Kisachek [45]

Answer:

D) use SQL or graphical tools to query the database            

Explanation:

To query the database using SQL or graphical tools will help Howie to retrieve bulk of records from the database according to his requirements and it will help to understand and work with the data in a better way than using the data in raw form.

SQL is a language of database used to manipulate and manage the data in the relational database and to query the database.

It is an easy and faster way to query using SQL or graphical tools because no coding is required here.

Different graphical tools are used to present the data in the database in a way that can be easily understood by a person. Different interfaces are provided to visualize the database tables or schema diagrammatically e.g in the form of graphs etc. Different views of the database can be provided to different users according to their requirement and what information they required to be presented.

6 0
3 years ago
Other questions:
  • what would happen if a large number of computer users are attempting to access a web site at the same time that you are
    15·2 answers
  • Jamie has to enter names, grades, and scores of a group of students into a worksheet. Which option will Jamie use to describe th
    11·1 answer
  • When creating an input/ output table, where do you enter the formula?
    5·1 answer
  • What financial behaviors will typically lead to a low credit score?
    14·1 answer
  • Write the definition of a method printarray, which has one parameter , an array of int s. the method does not return a value . t
    10·1 answer
  • Who initially developed what is now known as the internet?
    5·1 answer
  • Tradegy deals with _____
    14·1 answer
  • What is up with the bots? They are so annoying.
    9·2 answers
  • How do you render and export files on blender
    6·1 answer
  • Mrs. Schlair has an annual salary of $96,402.<br> a. What would her semimonthly salary be?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!