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
DedPeter [7]
3 years ago
8

For any element in keysList with a value greater than 50, print the corresponding value in itemsList, followed by a space. Ex: I

f keysList = {32, 105, 101, 35} and itemsList = {10, 20, 30, 40}, print: 20 30
JAVA

import java.util.Scanner;

public class ArraysKeyValue {
public static void main (String [] args) {

final int SIZE_LIST = 4;
int[] keysList = new int[SIZE_LIST];
int[] itemsList = new int[SIZE_LIST];
int i;

keysList[0] = 13;
keysList[1] = 47;
keysList[2] = 71;
keysList[3] = 59;

itemsList[0] = 12;
itemsList[1] = 36;
itemsList[2] = 72;
itemsList[3] = 54;
Computers and Technology
1 answer:
VARVARA [1.3K]3 years ago
5 0

Answer:

import java.util.Scanner;  //mentioned in the question.

public class ArraysKeyValue {  //mentioned in the question.

public static void main (String [] args) {  //mentioned in the question.

final int SIZE_LIST = 4; //mentioned in the question.

int[] keysList = new int[SIZE_LIST]; //mentioned in the question.

int[] itemsList = new int[SIZE_LIST]; //mentioned in the question.

int i; //mentioned in the question.

keysList[0] = 13; //mentioned in the question.                                

keysList[1] = 47; //mentioned in the question.

keysList[2] = 71; //mentioned in the question.

keysList[3] = 59; //mentioned in the question.

itemsList[0] = 12; //mentioned in the question.

itemsList[1] = 36; //mentioned in the question.

itemsList[2] = 72; //mentioned in the question.

itemsList[3] = 54;//mentioned in the question.

// other line to complete the solution is as follows--

for(i=0;i<(keysList.length);i++) //Loop to access all the element of keysList array variable.

    {// open for loop braces

        if(keysList[i]>50) // compare the value of keysList array variable with 50.

        System.out.println(itemsList[i]); // print the value

   }// close for loop braces.

}//  close main function braces.

} //close the class braces.

Output:

72

54

Explanation:

In the solution part--

  1. One loop is placed which moves from 0 to (size-1) of the 'keyslist' array.
  2. Then the 'if' statement is used to check the element of 'keyslist' array, which is greater than 50 or not.
  3. If it is greater, then print the element of item_list array of 'i' index which is also the index of greater value of keyslist array element.

You might be interested in
The expressions in each part of an AND or OR expression use ________ evaluation; that is, they are evaluated only as much as nec
I am Lyosha [343]

Answer:

The expressions in each part of an AND or OR expression use <u>Short Circuit</u> evaluation; that is, they are evaluated only as much as necessary to determine whether the entire expression is true or false.

Explanation:

Logic operations follow different type of evaluation methods that can be short circuit or open circuit evaluation. In short circuit evaluation if first operand of the expression is true or false in OR or AND operation respectively, the result will found as true or false without checking the second operand of the expression. This is called Short Circuit Evaluation.

In OR operation, If first operand is true it means that the result of the expression is true without knowing that the other operand is true or false. In AND operation, If the first operand is False, the result will found as False without knowing that whether the 2nd operand is  true or false.

This Mechanism is called Short Circuit Evaluation.

4 0
3 years ago
Producers must understand the marginal benefit of making an additional unit which shows the ...
yan [13]

Producers must understand the marginal benefit of making an additional unit which shows the possible gain. Marginal benefit is used in business and economics as a measurement of the change in benefits over the change in quantity. Possible gain is one example of benefit.  This measurement provides the relevant measurement of benefits at a specific level of production and consumption.

8 0
3 years ago
Read 2 more answers
When memory allocation is ____, it means all portions of the program and OS are loaded into sequential locations in memory.
OLga [1]

Answer:

Contiguous

Explanation:

A Contiguous memory allocation is known to be a classical memory allocation model. In this situation, we have a system which assigns consecutive memory blocks to a process. It is one of the oldest methods of memory allocation. If the process is in need of execution, the memory would be requested by the process. The processes size would then be compared to the amount of Contiguous memory that is available for the execution of the process.

3 0
3 years ago
Match the careers with the education required for each job
Gekata [30.6K]
Statistician for the last one network administaror for the next one then animator then broadcast tech
6 0
3 years ago
Which of the following for-loop headers results in equivalent numbers of iterations: A. for (int q = 1; q &lt;= 100; q++) B. for
vladimir2022 [97]

Answer:

b

Explanation:

C and D have equivalent iterations

C:       D:

99    990

90      900

81      810

72      720

63      630

54      540

45      450

36      360

27      270

18      180

9       90

8 0
3 years ago
Other questions:
  • You have a network that needs 29 subnets while maximizing the number of host addresses available on each subnet. How many bits m
    13·1 answer
  • Which cell formatting is most likely to use $?
    11·2 answers
  • What does the rule of five say?
    12·2 answers
  • describe a real-world scenario where data is collected and needs to be both accurate and precise for the safety of the community
    9·1 answer
  • The parts of a memo are _____.
    9·2 answers
  • Which of the following situations would not require knowledge of networking?
    11·2 answers
  • What are 3 similarities and 3 differences between live theatre and film/videos -Drama Class
    13·1 answer
  • A large number of consecutive IP addresses are available starting at 198.16.0.0. Suppose that four organizations, Able, Baker, C
    11·1 answer
  • What is a method that deletes an item from a list using the item’s value?
    11·1 answer
  • Full form of http.<br>wrong answer will be reported ​
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!