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
What is an advantage of a computer network ? networked
sergij07 [2.7K]

1. Data is easy to backup as all data is stored on the file server.

2.Network users can communicate by email and instant messenger.

5 0
3 years ago
Read 2 more answers
The Freeze Panes feature would be most helpful for which situation?
sergiy2304 [10]

Answer:

i think a but not so sure

Explanation:

6 0
3 years ago
A(n) _____ is the highest educational degree available at a community college. master bachelor associate specialist
baherus [9]
<span>An associate's degree requires two years of academic study and is the highest degree available at a community college</span>
5 0
3 years ago
Read 2 more answers
Calculate the performance of a processor taking into account stalls due to data cache and instruction cache misses. The data cac
zhuklara [117]

Answer:

- Calculate the additional CPI due to the icache stalls.

- Calculate the additional CPI due to the dcache stalls.  

- Calculate the overall CPI for the machine.

The additional CPI due to icache stalls = Hit Rate * Hit Latency + Miss Rate*  

Miss Penalty = 0.9*2 + 0.1*50 = 1.8 + 5 = 6.8  

The additional CPI due to dcache stalls = 0.92*2 + 0.08*124 = 11.76  

The overall CPI = 0.3*11.76 + 0.7*1.0 + 1.0*6.8 = 11.03 7.  

Explanation:

6 0
3 years ago
(1) Prompt the user to input an integer, a double, a character, and a string, storing each into separate variables. Then, output
Alex787 [66]

Answer:

import java.util.*;

public class Main{

public static void main(String[] args) {

    Scanner input = new Scanner(System.in);

 int intgVal; double dblVal; char chrVal; String strVal;

 System.out.print("Enter integer: ");  

 intgVal = input.nextInt();

 System.out.print("Enter double: ");  

 dblVal = input.nextDouble();

 System.out.print("Enter character: ");  

 chrVal = input.next().charAt(0);

 input.nextLine();

 System.out.print("Enter string: ");  

 strVal = input.nextLine();

 System.out.println(intgVal+" "+dblVal+" "+chrVal+" "+strVal);

 System.out.println(strVal+" "+chrVal+" "+dblVal+" "+intgVal);

 int IntValue = (int) dblVal;

 System.out.print("Cast to an integer: "+IntValue);

}

}

Explanation:

See attachment for complete program where comments were used to explain each line of the program

Download txt
6 0
3 years ago
Other questions:
  • Can someone tell me how to get all A's with no effort?
    5·1 answer
  • Write a program that accepts three decimal numbers as input and outputs their sums?​
    5·1 answer
  • Natural selection is a. how systems of rewards increase desired behaviors. b. the idea that the observable environment affects b
    6·1 answer
  • What is one course of action available in every problem solving process?
    9·2 answers
  • This project is to mimic a meeting request system by checking the requesting party’s validity, and the number of people attendin
    15·1 answer
  • NAT is able to stop ________. Group of answer choices a) scanning probes sniffers from learning anything about the internal IP a
    8·2 answers
  • Python: Bad input on line 8. What is the fix, please can someone tell me I’m desperate?
    10·1 answer
  • What happens if an email server cannot find a matching username or the mailbox is full
    14·2 answers
  • What do other people think of e.t ( be specifc by putting a line in the story)<br><br> E.T MOVIE
    11·1 answer
  • Mechanisms that can be used to rescue accident victims
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!