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
Where can the Ease of Access and Speech Recognition centers be found?
Bess [88]

Answer:

bottom right

Explanation:

at least on windows it's bottom right

3 0
3 years ago
Read 2 more answers
Nadia's productivity at work is being hurt due to the large quantity of unwanted e-mail she receives. What steps can she take to
anastassius [24]

Answer:

Hi,

The best option in the list is <u>stop posting her e-mail address on newsgroups.</u>

Explanation:

Unwanted e-mail is categorized as a spam email.These emails can not be entirely avoided because we use the Internet thus it is recommended that you filter them.A program called my email client can help to filter spam though in some cases, it might not be effective.

The techniques Nadia can employ in this case is to hidden her email address when visiting newsgroups.News groups are forums online where people discuss certain topic.Avoid publishing the email in these web sites can hide her tackle this problem. Additionally, Nadia could train the filter serach feature in her email box through repoting such emails using the report button present, avoid responding/openning spam  or use a third party program to track spam emails and block them.

Wish you Luck!

8 0
3 years ago
Which of the following changes the features (e.g., thickness of the line, shadow, 3-D effect, single or double, etc.) of the bor
lilavasa [31]
Border style
I hope it’s work
8 0
3 years ago
Add (total) all the number in the list (below) using a for loop, but skip over the number at index 3.
user100 [1]

Answer:

The program in Python is as follows:

numbers = [10,20,30,40,50,60,100]

total = 0

for i in range(len(numbers)):

   if i != 3:

       total+=numbers[i]

print(total)

Explanation:

This initializes the list

numbers = [10,20,30,40,50,60,100]

Set total to 0

total = 0

This iterates through numbers

for i in range(len(numbers)):

This ensures that the index 3, are not added

<em>    if i != 3:</em>

<em>        total+=numbers[i]</em>

Print the calculated sum

print(total)

3 0
2 years ago
The number of __________ to your website that had not visited prior to the time frame being analyzed.
liq [111]

Answer:

First Time Unique Visitor

Explanation:

I majored in

4 0
2 years ago
Other questions:
  • How is a cell named?
    9·1 answer
  • What is the best way to improve an online search
    6·2 answers
  • Select the correct answer.
    12·1 answer
  • The__ key is used to group or identify a field or record within a table. (you don't need it).
    5·2 answers
  • A function is executed when it is
    7·1 answer
  • Celeste is writing a paper. However, two pages in, her computer shuts down unexpectedly. She never saved her paper, and all her
    12·2 answers
  • 9. Which of the following is the<br>leading use of computer?​
    13·1 answer
  • You have a small business.Due to the recent pandemic you seem to be losing contacts with your suppliers and customers.You want t
    10·1 answer
  • True or false scientists investigate and seek to explain the natural world
    14·1 answer
  • Data mining requires specialized data analysts to ask ad hoc questions and obtain answers quickly from the system. select one: t
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!