answer.
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]
2 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]2 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
When handling project scope creep, which are two things that all parties involved need to be aware of?
WARRIOR [948]

Additional resource needed for the projects

Additional time needed for the project

<u>Explanation:</u>

In any project handing their will expected diversion and add on requirement, so to complete a project additional time and additional resource is required to finish a project.

As advice due the project details, end user has keep enough buffer for deviations on resource of man power and additional times taken to finish the project.

While design the project each scope of work is measure with additional time to complete the task

Each scope of work is considered as task in project management.

3 0
2 years ago
Write a program to declare a matrix A[][] of order (MXN) where ‘M’ is the number of rows and ‘N’ is the
Liula [17]

Answer:

import java.io.*;

import java.util.Arrays;

class Main {

   public static void main(String args[])

   throws IOException{

       // Set up keyboard input

       InputStreamReader in = new InputStreamReader(System.in);

       BufferedReader br = new BufferedReader(in);

 

       // Prompt for dimensions MxN of the matrix

       System.out.print("M = ");

       int m = Integer.parseInt(br.readLine());

       System.out.print("N = ");

       int n = Integer.parseInt(br.readLine());

       // Check if input is within bounds, exit if not

       if(m <= 2 || m >= 10 || n <= 2 || n >= 10){

           System.out.println("Matrix size out of range.");

           return;

       }

       // Declare the matrix as two-dimensional int array

       int a[][] = new int[m][n];

 

       // Prompt for values of the matrix elements

       System.out.println("Enter elements of matrix:");

       for(int i = 0; i < m; i++){

           for(int j = 0; j < n; j++){

               a[i][j] = Integer.parseInt(br.readLine());

           }

       }

       // Output the original matrix

       System.out.println("Original Matrix:");

       printMatrix(a);

       // Sort each row

       for(int i = 0; i < m; i++){

         Arrays.sort(a[i]);

       }

       // Print sorted matrix

       System.out.println("Matrix after sorting rows:");

       printMatrix(a);

   }

   // Print the matrix elements separated by tabs

   public static void printMatrix(int[][] a) {

       for(int i = 0; i < a.length; i++){

           for(int j = 0; j < a[i].length; j++)

               System.out.print(a[i][j] + "\t");

           System.out.println();

       }

   }

}

Explanation:

I fixed the mistake in the original code and put comments in to describe each section. The mistake was that the entire matrix was sorted, while only the individual rows needed to be sorted. This even simplifies the program. I also factored out a printMatrix() method because it is used twice.

4 0
2 years ago
Kendall receives an email stating that a leading computer company is giving away free computers, asking her to forward the email
gavmur [86]

Explanation:

Kendall should report the email as scam and delete email instead of forwarding it. She should also run her virus protection software as these kind of emails on the Internet are mostly Fraud and can contain virus so the user should avoid them.

8 0
2 years ago
The molecule 2,2-diisopropylheptane is incorrectly named. what is the correct name?
pentagon [3]
Isopropyl is: CH3 - CH - CH3
                                |

Heptane is: CH3 - CH2 - CH2 - CH2 - CH2 - CH2 - CH3

Then 2,2 isopropyl heptane is:

CH3 - CH - CH3
           |
CH3 - C - CH2 - CH2 - CH2 - CH2 - CH3
           |
CH3 - CH - CH3.

There you can count that the longest carbon chain has 8 carbon atoms.
So the right name is of an octane.

I will rearrange the chain to show the 8 carbon chain in a row:

           CH3   CH3
           |          |
CH3 - CH -   C - CH2 - CH2 - CH2 - CH2 - CH3
                      |
           CH3 - CH - CH3

Now, you can see that the right name is 3 isopropyl - 2, 3 dimethyl octane




5 0
2 years ago
Google Apps are an example of​ ________. A. platform as a service​ (PaaS) B. software as a product​ (SaaP) C. platform as a prod
iogann1982 [59]

Answer:

Option E is correct.

Google Apps are an example of​ software as a service (SaaS).

Explanation:

I'll provide definitions to each of them.

Platform as a Service (PaaS): hardware and software tools available over the internet.

Software as a product (SaaP): product, software, which is made to be sold to users, and users pay for licence which allows them to use it. A good example of SaaP is the Microsoft Office package.

Platform as a product (PaaP): This creates a platform for product owners to put their products & for people to get their required products.

Infrastructure as a Service (IaaS): cloud-based services, pay-as-you-go for services such as storage, networking, and virtualization.

Software as a Service (SaaS): software that's available via a third-party over the internet.

From these definitions, it is clear that Google apps are examples of software as a Service because all the Google apps are software's that's available via a third-party over the internet.

Hope this Helps!!!

6 0
2 years ago
Other questions:
  • A ____ partition contains the data necessary to restore a hard drive back to its state at the time the computer was purchased an
    8·2 answers
  • To gain experience of using and combing different sorting algorithms: election sort, insertion sort, merge sort, and quick sort.
    14·1 answer
  • Write a script that creates a user-defined database role named OrderEntry in the MyGuitarShop database. Give INSERT and UPDATE p
    8·1 answer
  • Which of the following is NOT a method in which a macro can be run?
    10·1 answer
  • Write a class with a constructor that accepts a String object as its argument. The class should have a method that returns the n
    13·1 answer
  • Insert the missing code in the following code fragment. This fragment is intended to call the Vehicle class's method. public cla
    14·1 answer
  • A news channel runs a two-minute story on phishing scams. The report features the testimonies of a phishing victim and a compute
    7·1 answer
  • Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two
    12·1 answer
  • a. a large central network that connects other networks in a distance spanning exactly 5 miles. b. a group of personal computers
    7·1 answer
  • You are having a problem with your Windows computer that is isolated to a single graphics editing program that you use every day
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!