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
Savatey [412]
3 years ago
15

create a function named dispAry. This function has 2 arguments, the first one is an integer array and second one is a integer to

indicate the size of the array. There will be no return value. In the function body the code should loop through the array that was passed and display its contents to the screen. Lastly write the code that calls the function and passes the salesCount array and the size of the array.
Computers and Technology
1 answer:
11Alexandr11 [23.1K]3 years ago
3 0

Answer:

The java program for the given scenario is as follows.

import java.util.Scanner;

import java.lang.*;

public class Main

{

   //variable declared static and initialized

   static int size=10;

   //array declared static  

   static int[] salesCount = new int[size];

   //method to display array

   static void dispAry(int[] arr, int len)

   {

       for(int j=0; j<len; j++)

       {

           System.out.println(arr[j]);

       }

   }

public static void main(String[] args) {

//array initialized in for loop

   for(int j=0; j<size; j++)

   {

       salesCount[j]=j*2;

   }  

    //method called to display array

    dispAry(salesCount, size);

}

}  

OUTPUT

0

2

4

6

8

10

12

14

16

18

Explanation:

1. A static integer variable, size, is declared and initialized to 10.

2. A static integer array, salesCount, is declared. This array is initialized inside main().

3. A static method, dispAry(), is defined which takes two parameters: an array and an integer variable indicating size of that array.

4. This method only displays the contents of the array.

5. Inside main() method, the array, salesCount, is initialized and passed as a parameter to the method, dispAry(), along with the integer variable, size.

6. The program can be tested for any value of variable, size, which indicates length of the array.

7. The values in the array are double the index of each element; each index is multiplied by 2 and assigned to the element at that particular index.

8. The program can be tested for any numerical values in the array.

9. Since two methods are required, program is written in java language.

10. Each element of the array are printed on a new line using the method println().

11. All the elements of the array can be printed on the same line, separated by space, using method print().

12. In java, all coding is written inside the class. Only variables can be declared at class level, inside class and outside methods. All the logic is to be placed inside methods.

You might be interested in
Subscribe to my you tube channel to get all your questions answered
vredina [299]

kaaaaaaaaaaaaaaaaa

aaa

4 0
3 years ago
Using symbols in a file name is a good idea.<br><br> True<br> False
zavuch27 [327]
False. File names should only contain letters, underscores, periods, and dashes.
4 0
3 years ago
Read 2 more answers
What type of Windows server has Active Directory installed and is responsible for allowing client computers access to domain res
Basile [38]

Answer:

Domain controller                    

Explanation:

  • A domain controllers is a server which acknowledges authentication requests and validates users access on the computer network in order to use the resources.
  • This is done by the domain controller by verifying the username and password.
  • It also allows user to access the other domain and also access the resources of other domain.
  • For example there is a network of multiple computers and each computer requires authentication i.e user is asked to provide the username and password.
  • Authenticating every computer and managing is not easy so a computer is appointed this task of authentication other computers.
  • This computer  is called domain controller which can easily maintain these authentication details of the users.
  • The authentication information (login details) of users, computers and shared resources is saved in Active Directory database.
  • If a user requests access to the resource via login then the login details (username and password) of the user should match with that stored in the Active Directory in order to grant access to the user.
  • Domain controller enables resources sharing and is good for large networks and provides with improved security.
4 0
3 years ago
What if an input is always the same for an algorithm? <br> (Plz do not answer if you don’t know)
skelet666 [1.2K]
Given a particular input, will always produce the same output, with the underlying machine always passing through the same sequence of states.
5 0
3 years ago
Which of the following is not a scene mode?
tatiyna
I believe the answer is C) Model.
7 0
4 years ago
Read 2 more answers
Other questions:
  • Directions: pick the right letter for each number.
    11·2 answers
  • Have main create two objects: setA and setB.Input the values into setA (end with a 0 or negative) and input the values into setB
    12·1 answer
  • Maya enjoys connectedWith her friends and social media apps but one of her friends post a lot of stuff that my thinks it’s annoy
    14·1 answer
  • Which method is the best way to keep from running late on the day of a test
    10·1 answer
  • Consider the following scenario below and recommend a solution.
    8·1 answer
  • Focusing on a target market makes it harder to develop products and services that specific groups of customers want.
    10·1 answer
  • What is versatility according to computer​
    11·1 answer
  • 1. Which of the following is not a question that should be asked when planning a Windows Server 2019 installation?
    13·1 answer
  • Function of Ribbon in Access 2010​
    7·1 answer
  • i was wondering if anybody would have a season 1 or 2 or 3 Fortnight account they never use and was gonna ask if i could play on
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!