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
Difference between softcopy and hardcopy​
Rashid [163]

A hard copy is the digital file, stored in a device and was printed out. A soft copy is the electronic version NOT PRINTED. It is showcased digitally (through a phone, computer, flash drive etc)

3 0
3 years ago
Read 2 more answers
Why is it important to have regular maintenance and care of your office equipment?
mr Goodwill [35]
It is important to have regular maintenance on office equipment because by having regular maintenance they would be able to determine if a problem is about to occur on the office equipment before it puts the equipment out of commission. This would save money for the office because they would be able to fix the problem cheaper than buying new equipment.
3 0
3 years ago
A single central register of IP addresses and names (a DNS style system) is an efficient means of translating human readable nam
Harrizon [31]

Answer:

True

Explanation:

DNS stands for "Domain Name System" DNS is the system/service that is used to convert the Domain Names into IP addresses.

Whenever we write a URL to go to a web page in our browser for example Brainly(dot)com, the request first goes to a server which converts the named URL(Brainly(dot)com) into actual IP address. This actual IP address is then used to reach to the web files, as response to the URL search. This system is made to ease out the searches made by the users.

Therefore, the given statement is True.

8 0
4 years ago
A counter is a tool used to measure the number of times people visit a Web site. true or false?
Liono4ka [1.6K]

True.

It doesn't measure unique users, so you can just hit refresh and the counter keeps going up...

5 0
3 years ago
Along a road lies a odd number of stones placed at intervals of 10 metres. These stones have to be assembled around the middle s
nikitadnepr [17]

Answer:

hope this helped you,(ㆁωㆁ)

3 0
4 years ago
Other questions:
  • When using powershell, an administrator can use the ____________ cmdlet to create a new dc in a new forest.??
    14·1 answer
  • Which of the following JavaScript methods is used to define an object collection based on a CSS (Cascading Style Sheets) selecto
    15·1 answer
  • How do productivity programs most benefit the way we work and live?
    15·1 answer
  • What are the two types of computers
    15·2 answers
  • Which is a group of related software applications that are bundled and sold together?
    9·2 answers
  • How do you know where the home row of the keyboard is?
    14·2 answers
  • Create a dynamic array of 100 integer values named myNums. Use a pointer variable (like ptr) which points to this array. Use thi
    6·1 answer
  • The programming interface for a legacy motor controller accepts commands as binary strings of variable lengths.
    15·1 answer
  • What is system software?
    14·1 answer
  • Taran wants to work in the technology field but is unsure of which career to pursue. He has been told he has strong people skill
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!