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
Ira Lisetskai [31]
2 years ago
13

You are asked to write a program that prompts the user for the size of two integer arrays, user input for the size must not exce

ed 50, you must validate this. We will use these arrays to represent our sets. These arrays will be randomly populated in the range that is 1 through double the size of the array. So if the array is of size 20, you will randomly populate it with values in the range 1-40 inclusive.
Computers and Technology
1 answer:
Zielflug [23.3K]2 years ago
4 0

Answer:

In Java:

import java.util.*;

public class MyClass{

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 System.out.print("Length of array 1: ");

 int lent1 = input.nextInt();

 while(lent1 <= 0 || lent1 > 50){

     System.out.print("Length of array 1: ");

     lent1 = input.nextInt();

 }

 int[] array1 = new int[lent1];

 System.out.print("Length of array 2: ");

 int lent2 = input.nextInt();

 while(lent2 <= 0 || lent2 > 50){

     System.out.print("Length of array 2: ");

     lent2 = input.nextInt();

 }

 int[] array2 = new int[lent2];

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

     array1[i] = (int)(Math.random() * (lent1*2) + 1);

 }

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

     array2[i] = (int)(Math.random() * (lent2*2) + 1);

 }

 System.out.print("Array 1: ");

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

     System.out.print(array1[i]+" ");

 }

 System.out.println("Array 2: ");

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

     System.out.print(array2[i]+" ");

 }

}

}

Explanation:

This prompts the user for length of the first array

 System.out.print("Length of array 1: ");

This declares and gets input for the length of the first array

 int lent1 = input.nextInt();

This validates the length of first array

<em>  while(lent1 <= 0 || lent1 > 50){</em>

<em>      System.out.print("Length of array 1: ");</em>

<em>      lent1 = input.nextInt();  }</em>

This declares the first array

 int[] array1 = new int[lent1];

This prompts the user for length of the second array

 System.out.print("Length of array 2: ");

This declares and gets input for the length of the second array

 int lent2 = input.nextInt();

This validates the length of the second array

<em>  while(lent2 <= 0 || lent2 > 50){</em>

<em>      System.out.print("Length of array 2: ");</em>

<em>      lent2 = input.nextInt();  }</em>

This declares the second array

 int[] array2 = new int[lent2];

The following generates random integers between 1 and lent1*2 to array 1

<em>  for(int i =0;i<lent1;i++){</em>

<em>      array1[i] = (int)(Math.random() * (lent1*2) + 1);  }</em>

The following generates random integers between 1 and lent2*2 to array 2

<em>  for(int i =0;i<lent2;i++){</em>

<em>      array2[i] = (int)(Math.random() * (lent2*2) + 1);  }</em>

This prints the header Array 1

 System.out.print("Array 1: ");

The following iteration prints the content of the first array

<em> for(int i =0;i<lent1;i++){</em>

<em>      System.out.print(array1[i]+" ");</em>

<em>  }</em>

This prints the header Array 2

 System.out.println("Array 2: ");

The following iteration prints the content of the second array

<em>  for(int i =0;i<lent2;i++){</em>

<em>      System.out.print(array2[i]+" ");</em>

<em>  }</em>

<em />

You might be interested in
To create a multiple-table form based on the âmanyâ table, tap or click the ____ button on the create tab to create a form in la
Archy [21]
Click on the blank form button. 
3 0
3 years ago
There are numerous strict and steadfast rules when it comes to composition.
erastova [34]

Answer:

false

Explanation:

none ¯\_(ツ)_/¯

6 0
2 years ago
Nowadays computer games are mostly available on external<br> hard disk.<br> Is it true or false?
sergey [27]

Answer:

false

Explanation:

because a lot of times they are downloads without the disk

7 0
3 years ago
Read 2 more answers
Configuration reviews are not needed if regression testing has been rigorously applied during software integration.
goldfiish [28.3K]
B) False, reviews and constant matinese is always needed, reviews help the creators understand what people think needs work and what they like, the updates on the site will implement these wants and needs.
8 0
3 years ago
Describe at least three of the characteristics that project managers look for in project participants and explain why you think
Vera_Pavlovna [14]

Answer:

1. Knowledge of Project Management Principles: A project participant should have the required knowledge of how project management works and how to function well in a team to achieve a common goal.

2. Time management skills: Despite the fact that it might be teamwork, the effectiveness of each individual is key. Every team member should be able to meet deadlines so as not to burden the team when they are given an individual task.

3. Excellent Communicator: A project participant should be able to communicate well with other team members, the project manager, different audiences, even customers and potential customers. Any weakness in communication skills could affect the project generally.

<u>why you think they are important</u>

1. Having knowledge of project management principles would lessen work and save time for the project manager and other team members as the project participant would have an idea per time of what to do.

2. A project participant that can manage time would generally increase the efficiency of the company, help the company meet deadlines, help the team meet targets.

3. Any weakness in communication skills could affect the project generally.

6 0
3 years ago
Other questions:
  • An example of hardware is a _____. database spreadsheet monitor program used to enhance photos
    13·2 answers
  • In order to prevent unauthorized access, how can the shadow file be configured to enforce a password policy?​ What happens to ac
    6·1 answer
  • How did mechanical clocks assist in completing work? How was work done previously?
    12·1 answer
  • Which key should you press to leave the cell as it originally was?
    15·1 answer
  • A strategy to solve a logic problem is to break it into steps. Using the drop-down menu, complete these sentences about solving
    15·2 answers
  • To lose weight, you must _______.
    10·2 answers
  • What do you do when you have computer problems? Check all that apply. PLEASE HELP
    9·2 answers
  • 9.
    15·1 answer
  • Plsss help me<br>give two examples of problems that can occur when sytems do not work properly​
    9·1 answer
  • What are the impacts of mobile phone?as well as the positive and negative impacts?​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!