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
Ronch [10]
3 years ago
6

Exercise#3: Write a ch program that performs the following: Declare a two arrays called arrayA and arrayB that holds integer and

the size of each array is given by the user. b. The main method calls a method called fillArray(...) of type void to fill an array with a set of generated random integers between low and high (both inclusive). This method should be called twice to fill arrayA and then arrayB. (the values of High and low are read in the main method. ​
Computers and Technology
1 answer:
Serga [27]3 years ago
6 0

Answer:

The code for this problem is completed here. Comments are added, go and learn how things work.

Explanation:

// Arrays.java

import java.util.Random;

import java.util.Scanner;

public class Arrays {

     // method to fill an array with random numbers between low and high

     static void fillArray(int array[], int low, int high) {

           Random random = new Random();

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

                 // generating a value between low and high inclusive, adding to

                 // array

                 array[i] = random.nextInt(high - low + 1) + low;

           }

     }

     // method to print elements in an array

     static void printArray(int array[]) {

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

                 // displaying elements separated by tab space

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

                 // printing a line break after every 5th element, or if this is the

                 // last element.

                 if ((i + 1) % 5 == 0 || i == array.length - 1) {

                       System.out.println();

                 }

           }

     }

     // method to count the number of elements in array greater than value

     static int count(int array[], int value) {

           // initializing count to 0

           int c = 0;

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

                 if (array[i] > value) {

                       // incrementing c

                       c++;

                 }

           }

           return c;

     }

     // returns true if two arrays are same, else false

     static boolean isSame(int array1[], int array2[]) {

           if (array1.length != array2.length) {

                 // lengths mismatch

                 return false;

           }

           // checking if elements are same in same order

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

                 if (array1[i] != array2[i]) {

                       // mismatch found

                       return false;

                 }

           }

           // same

           return true;

     }

     // returns the average of elements in an array

     static double findAverage(int array[]) {

           double sum = 0;

           // summing values

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

                 sum += array[i];

           }

           // finding average

           double avg = (double) sum / array.length;

           return avg;

     }

     // method to count the number of values greater than average of an array

     static int aboveAverage(int array[]) {

           // finding average of passed array using findAverage method

           double avg = findAverage(array);

           // finding number of elements in array>avg using count method

           int c = count(array, (int) avg);

           return c;

     }

     public static void main(String[] args) {

           // setting up a Scanner

           Scanner scanner = new Scanner(System.in);

           // prompting and reading size of arrayA

           System.out.print("Enter size of arrayA: ");

           int n1 = scanner.nextInt();

           // initializing arrayA

           int arrayA[] = new int[n1];

           // doing the same for arrayB

           System.out.print("Enter size of arrayB: ");

           int n2 = scanner.nextInt();

           int arrayB[] = new int[n2];

           // asking and reading low and high values

           System.out.print("Enter low and high values for random numbers: ");

           int low = scanner.nextInt();

           int high = scanner.nextInt();

           // filling both arrays

           fillArray(arrayA, low, high);

           fillArray(arrayB, low, high);

           // printing both arrays

           System.out.println("arrayA:");

           printArray(arrayA);

           System.out.println("arrayB:");

           printArray(arrayB);

           // reading an integer

           System.out.print("Enter an integer value: ");

           int value = scanner.nextInt();

           // displaying the number of elements in each array greater than above

           // value

           System.out.println("The number of elements greater than " + value

                       + " in arrayA: " + count(arrayA, value));

           System.out.println("The number of elements greater than " + value

                       + " in arrayB: " + count(arrayB, value));

           System.out.println("Both arrays are same: " + isSame(arrayA, arrayB));

           // finding and displaying average of arrayA

           double avgA = findAverage(arrayA);

           System.out.println("Average of all values in arrayA: " + avgA);

           // finding and displaying number of elements in arrayB greater than the

           // average of arrayB

           System.out.println("The number of elements greater than "

                       + "the average of arrayB" + " in arrayB: "

                       + aboveAverage(arrayB));

     }

}

You might be interested in
When ordering a new​ zagflatz, customers must choose the style of three major​ components, each of which has about ten variation
patriot [66]

Answer:

C. modular design

Explanation:

Based on the information provided it can be said that in this scenario being able to choose the style that you want is an example of a modular design. A modular design refers to when something is divided into various parts called modules that can be independently chosen and/or exchanged in order to create a customized object. Which is exactly what is allowed in this scenario when ordering a new zagflatz.

6 0
3 years ago
I live in Pennsylvania which observes eastern standard time.
goldfiish [28.3K]

Answer:

mudar o horário de acordo com a vista

Explanation:

4 0
2 years ago
Nate specifically wants a template that will work for an application letter. Which features in the New dialog box can
Pavel [41]

Answer:

We can find our required template with the help of followings:

1. Search

We can search our required template from new dialog box. We just enter the name of our required template in search bar and will find the required one.

2. Scroll Bar

By using scroll bar, we can scroll up and down to find the required template.

3. Categories List

We also can find the required template, that may be defined as category. In categories list we can also find the required template.

3 0
3 years ago
One of the primary principles of the Rapid Application Development methodology is early prototyping of the _______ in the develo
Oliga [24]

Answer:

Software Applications

Explanation:

Rapid Application Development (RAD) also is an agile project management strategy used in the development of software. RAD is also referred to as Rapid Application Building (RAB).

Its greatest advantage is that it reduces the time taken to churn out a program and this is why a lot of developers are now adopting it.

This is made possible by reducing the amount of time and effort spent on planning and increasing the amount of energy spent on creating prototypes.

Other merits of this methodology are:

  1. It reduces the risk associated with the project by ensuring that the program is first used as a prototype rather than the real deal.
  2. It ensures better quality. When users interact with the prototypes, they are able to provide very useful feedback that goes back into development to enhance the quality of the project.

Cheers!

3 0
3 years ago
After a group sets a project schedule, members should be prepared to
Roman55 [17]

After a group sets a project schedule, members should be prepared to complete a study-time survey to prove they can do the work.

<h3>What is a group project?</h3>

A group project is a project in which more than one person work together. Group projects are given to improve the work, as various minds can bring out various implements for the project.

Thus, the correct option is D. complete a study-time survey to prove they can do the work.

Learn more about group project

brainly.com/question/14488746

#SPJ1

3 0
2 years ago
Other questions:
  • Describe in one or more complete sentences how someone starting a computer repair business in a town night gain a competitive ad
    15·1 answer
  • What does zooming do? A. Changes your view of the Frame Editor to be closer or farther away B. Changes your view of the Event Ed
    12·1 answer
  • Wich is the last step in conducting a URL search
    14·2 answers
  • Your friend’s parents are worried about going over their budget for the month. Which expense would you suggest is NOT a need?
    10·2 answers
  • 0x400C (in hexadecimal)?
    8·1 answer
  • Suppose that class OrderList has a private attribute double cost[100] which hold the cost of all ordered items, and a private at
    14·1 answer
  • "A user reports that the corporate web server cannot be accessed. A technician verifies that the web server can be accessed by i
    8·1 answer
  • Define a new class Fighter that inherits from Spaceship. Add a variable property weapon that defaults to an empty string and a v
    14·1 answer
  • Why is it important to put the most specific case first? What types of errors does it help avoid?
    11·1 answer
  • True or false: if you are adding your own css sheet, make sure your css file comes before the bootstrap css file.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!