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

Exercises: Solve the following problems on paper and bring your sheet of paper to your section on Thursday: Consider the followi

ng method: public static void arrayMystery(int[] array) { for (int i = 0; i < array.length - 1; i++) { if (array[i] < array[i + 1]) { array[i] = array[i + 1]; } } } Indicate what values would be stored in the array after the method arrayMystery executes if each integer array below is passed as a parameter to it. a. input = {2, 4} b. input = {1, 3, 6} c. input = {7, 2, 8, 4} d. input = {5, 2, 7, 2, 4} e. input = {2, 4, 6, 3, 7, 9}
Computers and Technology
1 answer:
Volgvan3 years ago
4 0

Answer:

Hi Lzvcorri! Based on the inputs, we can expect the answers:

a. [4, 4]

b. [3, 6, 6]

c. [7, 8, 8, 4]

d. [5, 7, 7, 4, 4]

e. [4, 6, 6, 7, 9, 9]

Explanation:

For a, the input is {2,4} so the array length is 2, and the loop will run for array.length - 1. So the first run with this array will see if array[i] (i=0 as initially set in the for loop with the statement "for (i=0;)") is less than the value in the array after it, array[i+1]. Since 2, is less than 4, it will assign the value of 4 in the first array index as per this condition being met (array[i] = array[i + 1];). Similarly, if you trace the execution of the program with the remaining inputs b, c, d, and e, you should expect the resultant array as in the answer above.

You might be interested in
Filtering is a function of _____.
Levart [38]
The answer is: switches.

Explanation:

Filtering is a function of switches.
3 0
2 years ago
Consider the function definition void Demo( int&amp; intVal, float floatVal ) { intVal = intVal * 2; floatVal = float(intVal) +
Fynjy0 [20]

Answer:

myInt=40

myFloat=4.8

Explanation:

First look at the function definition .It has two arguments intVal is passed by reference while floatVal is passed by value.So the changes done on the myInt variable will be reflected on the original argument because when a variable is passed by reference the the changes are reflected on the original argument but when a variable is passed by value the function created a duplicate copy of it and work on them so changes are not reflected on the original argument.So myInt will get doubled while myFloat will remain the same.

5 0
3 years ago
Write a loop that reads positive integers from standard input and that terminates when it reads an integer that is not positive.
puteri [66]

Answer:

import java.util.Scanner;

public class num4 {

   public static void main(String[] args) {

     Scanner in = new Scanner(System.in);

     int sumOdds =0;

     int sumEvens =0;

     int num;

     do{

         System.out.println("Enter positive integers");

         num = in.nextInt();

         if(num%2==0){

             sumEvens+=num;

         }

         else if (num%2!=0){

             sumOdds+=num;

         }

     }while (num>0);

       System.out.println("The sum of evens: "+sumEvens);

       System.out.println("The sum of odds: "+sumOdds);

   }

}

Explanation:

  • Import Scanner class to prompt and receive user input
  • Declare the following variables and initialize them int sumOdds =0, int sumEvens =0, int num;
  • Create a do....while loop That continously prompts user to enter a positive number. The loop should terminate when a negative number is enters (n<=0)
  • Within the while loop use an if condition with the modulo (%) operator to determine even and odd numbers and add to the respective variables
  • Outside of the while loop Print sum of odds and sum of evens

5 0
3 years ago
You would like the word "Employee" to appear in cells A1, B1, C1, D1, and E1. To be efficient, you should
Agata [3.3K]

Answer: type the label in A1 and use autofill

Explanation:

Took the final 2021 Edgeunity

6 0
3 years ago
43
pshichka [43]

Answer:

c

Explanation:

5 0
2 years ago
Read 2 more answers
Other questions:
  • If you choose a career, you will always be satisfied with your work.<br> True<br> False
    7·2 answers
  • A computer that stores and distributes newsgroup messages is called a newsreader.
    13·1 answer
  • 13) What are the benefits and detriments of each of the following? Consider both the systems and the programmers’ levels. a. Sym
    14·1 answer
  • What is information technology?
    12·1 answer
  • 1.<br> The correct way to use a seat belt is
    8·1 answer
  • List the memory units inside and outside of the CPU, along with short descriptions of their
    11·1 answer
  • According to a case study in one of our weekly chapter reading, nearly..................... percent of all employees send work e
    11·2 answers
  • Write a function that will sum all of the numbers in a list, ignoring the non-numbers. The function should takes one parameter:
    8·1 answer
  • You can put ______ on your phone.
    10·1 answer
  • How do you answer a question on Brainly if there's already at least one answer? It should be possible, since I've seen questions
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!