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
kakasveta [241]
3 years ago
15

In JAVA please:

Computers and Technology
1 answer:
blagie [28]3 years ago
5 0

Answer:

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;  

/* Your solution goes here */

for ( i = 0; i < SIZE_LIST; i++){

 if (keysList[i]>50){

  System.out.println(itemsList[i] + " ");  }  }

System.out.println("");

}

}

Explanation:

I will explain the whole program flow.

  • There are two arrays here
  • keysList and itemsList
  • The first list (keysList) contains the following elements:

13 element at first position of the array (0th index)

47 element at second  position of the array (1st index)

71 element at third position of the array (2nd index)

59 element at fourth position of the array (3rd index)

  • The other list (itemsList) contains the following elements:

12 element at first position of the array (0th index)

36 element at second  position of the array (1st index)

72 element at third position of the array (2nd index)

54 element at fourth position of the array (3rd index)

  • The size of the array elements is fixed which is 4 and is stored in the variable SIZE_LIST.
  • Then the loop starts. The loop contains a variable i which is initialized to 0. First it checks if the value of i is less than the size of the list. It is true as SIZE_LIST=4 and i=0.
  • So the program control enters the body of the loop.
  • In first iteration, IF condition checks if the i-th element of the keysList is greater than 50. As i=0 So the element at 0th index of the keysList is 13 which is not greater than 50 so the body of IF statement will not execute as the condition evaluates to false. The value of i increments by 1 so now i becomes 1.
  • In next iteration loop again checks if the value of i is less than the size of the list which is true again so the body of the loop executes.
  • IF condition checks if the i-th element of the keysList is greater than 50. As i=1 So the element at 1st index of the keysList is 47 which is not greater than 50 so the body of IF statement will not execute as the condition evaluates to false. The value of i is incremented by 1 so now i becomes 2.
  • In next iteration loop again checks if the value of i is less than the size of the list which is true again as i= 2 which is less than SIZE_LIST so the body of the loop executes.
  • IF condition checks if the i-th element of the keysList is greater than 50. As i=2 So the element at 2nd index of the keysList is 71 which is greater than 50 so the body of IF statement is executed as the condition evaluates to true. So in the body of the IF statement there is a print statement which prints the i-th element of the itemsList. As i = 2 so the value at the index 2 of the itemsList is displayed in the output which is 72. Next value of i is incremented by 1 so now i becomes 3.
  • In next iteration loop again checks if the value of i is less than the size of the list which is true again as i= 3 which is less than SIZE_LIST so the body of the loop executes.
  • IF condition checks if the i-th element of the keysList is greater than 50. As i=3 So the element at 3rd index of the keysList is 59 which is greater than 50 so the body of IF statement is executed as the condition evaluates to true. So in the body of the IF statement there is a print statement which prints the i-th element of the itemsList. As i = 3 so the value at the index 3 of the itemsList is displayed in the output which is 54. Next value of i is incremented by 1 so now i becomes 4.
  • In next iteration loop again checks if the value of i is less than the size of the list which is now false as i=4 which is equal to the SIZE_LIST= 4. So the loop breaks.
  • So the output of the above program is:

72

54

You might be interested in
Which of the following would allow for the QUICKEST restoration of a server into a warm recovery site in a case in which server
adelina 88 [10]

Answer: C. Differential backup

Explanation: There are several ways od ensuring the preservation and storage of data even cases of disaster, one of such ways is data data mirroring which allows data to be replicated or copied in real time and several backup options. In cases where there there is need to restore a server, the warm recovery site provides a data or disaster recovery option used to mitigate the effect of data loss on organization. In the absence of data mirroring, differential backup option, provides the quickest recovery option as it only requires changes in the data stored after the last full backup. These speed experieced should be expected due to the relatively low data been dealt with rather than the entire data.

5 0
3 years ago
What would happen without satellites???
laila [671]

Answer: without satellites there would be no way for the world to communicate

Explanation:

4 0
3 years ago
Read 2 more answers
What are 3 ways to get friends to stop texting and driving?
Leni [432]
Not allow them to use their phone, tell them you won’t get in the car with them unless they stop texting and driving, inform their parents
3 0
2 years ago
Read 2 more answers
A plan to budget time for studying and activities is referred to as a study routine. study habits. study skills. a study schedul
vesna_86 [32]

Answer:

A study routine

Explanation:

6 0
3 years ago
Read 2 more answers
100POINTS!!!!
Anettt [7]

Answer:

Is it a tool in the computer, pls make it clear

6 0
2 years ago
Read 2 more answers
Other questions:
  • The main differences between laptops and desktop computers other than size and portability.
    14·1 answer
  • Explain why testing can only detect the presence of errors, not their absence.
    14·1 answer
  • If i throw papers in the dryer to help them dry faster could that mess up the dryer?
    5·1 answer
  • When you think of computers, I want you to think:
    7·1 answer
  • S.B. manages the website for the student union at Bridger College in Bozeman, Montana. The student union provides daily activiti
    7·1 answer
  • What should be entered to make the loop print
    6·1 answer
  • Plzz help me with this question.........
    6·1 answer
  • your manager asks you to set up a secure network connection at a remote site to move over some backups which protocol would you
    14·1 answer
  • WILL GIVE BRAINLIEST!! NO LINKS!!!
    12·2 answers
  • In additon to setting up services, what other tasks does a sysadmin have to keep in mind? check all that apply.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!