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
Mademuasel [1]
3 years ago
14

Create a new class MyArray_DE and copy and paste the previous program. Be sure to rename the class to MyArray_DE. Modify the pro

gram so that it sums up only the even numbers. PART E. At the end of the program, write a FOR loop that prints the array in reverse (you are not reversing the array; you are simply printing it). Test your program with all the above test cases.
Computers and Technology
1 answer:
vova2212 [387]3 years ago
4 0

Answer:

public class MyArray_DE

{

public static void main(String[] args) {

    int[] numbers = {28, 7, 92, 0, 100, 77};

    int total = 0;

    for (int i=0; i<numbers.length; i++){

        if(numbers[i] % 2 == 0)

            total += numbers[i];

    }

 System.out.println("The sum of even numbers is " + total);

 System.out.println("The numbers in reverse is ");

 for (int i=numbers.length-1; i>=0; i--){

        System.out.print(numbers[i] + " ");

    }

}

}

Explanation:

Since you did not provide the previous code, so I initialized an array named numbers

Initialize the total as 0

Create a for loop that iterates through the numbers

Inside the loop, if the number % 2 is equal to 0 (That means it is an even number), add the number to total (cumulative sum)

When the loop is done, print the total

Create another for loop that iterates through the numbers array and print the numbers in reverse order. Note that to print the numbers in reverse order, start the i from the last index of the array and decrease it until it reaches 0.

You might be interested in
When should an individual consider entering parenthood?
-BARSIC- [3]
  In my opinion, after marriage. And during the time you're married, be sure you are going to stay with that person a long time because divorces can cause mental health issues towards the child. And if your loved one is abusive, an alcoholic, etc. then you should get out that relationship immediately before having children. Therefore, your children will have a happy, healthy, life. 
5 0
3 years ago
Which of the following C++ statements displays a random number in the range 1 through 10?
lilavasa [31]

Answer:

Option(e)

Explanation:

rand() function results into a random number between 0 to a maximum number RAND_MAX which is a constant. To range it from 1, 1 is added and to decide its maximum value it should be modulo with that number. For example - if a number generated is 56 the 56%10 will be 6 which is in the range of 1 to 10. Option(a) is same as Option (b) because 1 is added and then subtracted which is neutral. Similarly, option (c) is also same.

7 0
3 years ago
Assume that a function named swapdoubles has been defined and is available for use in this exercise: that function receives two
Nata [24]

Answer:

C++ Code:

void sort3(double &a, double &b, double &c)

{

   if(a > b)

       swapdoubles(a,b);

   if (b > c)

       swapdoubles(b,c);

   if (a > b)

       swapdoubles(a,b);

}

Explanation:

To change the values of a,b,c within the function, we pass the values by reference. Let us assume that number a = 3.14, b = 2.71, c = 3.04. Since a > b, values of a and b will be swapped.Now a = 2.71 and b = 3.14. Similariy, since b > c, they will be swapped. This way, we move the largest number to its correct position in the first two steps. If there are only three numbers, and the largest number is in its correct position, then for the two remaining numbers, we will only need atmost one swap to exchange their positions. hence, we perform a comparison of a > b once again to see if the b is smaller than a. if its not, then all a,b,c are in sorted order.

6 0
3 years ago
What is the benifet of the manager feature
Masja [62]

Answer: Benefits managers administer an organization's employee benefits program, which may include retirement plans, leave policies, wellness programs, and insurance policies such as health, life, and disability.

Explanation:

8 0
3 years ago
How to write "There are four parking spots on campus that may be used only by Nobel Prize winning faculty." this sentence correc
dexar [7]
"On campus there are four parking spots, that may only be used by Nobel Prize winning faculty"

That's how I would write the sentence.
5 0
4 years ago
Other questions:
  • Which expansion slot is used by an NVMe compliant device?
    9·1 answer
  • How do you do these questions? The first two questions could have multiple answers and the third is one answer only.
    7·1 answer
  • When you type into a basic search engine like Google, Bing, or Yahoo!, the sites that appear at the top or on the side of the re
    7·1 answer
  • Study the sentence below
    13·2 answers
  • How does cryptocurrency exchange software works?
    14·1 answer
  • About twice a day my Chromebook blacks out. why does it do that?
    8·2 answers
  • Does trend in computing important for organization management?​
    8·1 answer
  • How many times will it tack when you fill 1 - liter of jar with water from the pond and uses 100 - milliliter cup to scoop water
    12·1 answer
  • What is a network computer that processes requests from a client server​
    11·1 answer
  • If you want to load the "my-data.csv" file to Dataframe so that you can explore find out the number of data items in the data se
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!