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
Write a paragraph on the importance of backing up data and mention at least three ways to back up data from your computer.
Scrat [10]

Answer:

Data backup is probably the most important part of any IT system. Backing up your data means periodically saving a copy of your computer’s information to an offsite location for safe keeping. Having a copy of your computer’s data protects it from being lost in the event of a hard drive failure

Explanation:

1-     On a Hard Drive (Onsite Backup)

2-     Online Backup Services (Offsite Backup)

3-     Cloud Backup Services (Offsite Backup)

5 0
4 years ago
What is the output of this program?
Leto [7]

Answer:

70 is the answer negative one begins from 83 and count down to 89, Therefore, 70 is is -4 and is chosen as the best answer

7 0
3 years ago
In most presentation software, custom animations are added from the _____.
gtnhenbr [62]

Answer:

Explanation:

the answer is.....normal view

8 0
3 years ago
would an electromagnet with a 3.7 volt lithium ion battery have an effect on devices and/or satelite signals like cell phones​
liraira [26]

Answer:

Some effect is there buts its almost negligible, and much less as compared to Ni-Cad batteries. Also this battery if recyclable, less toxic as well as remain in use for a very long time. Its used in satellites as well, and in one of them, it is now running without any fault for almost 13 years.

Explanation:

And you should check the list of noble price. Three great scientists John B. Goodenough, Akira Yoshino and Stanley Whittingham have got the noble prize for their work on Lithium Ion Batteries this year.

3 0
3 years ago
Most nosql data stores were created to address problems associated with storing large amounts of distributed data in __________.
finlep [7]
NoSQL is primarily designed for supporting the decision making systems. Most NoSQL data stores were created to address problems associated with storing large amounts of distributed data in relational database management systems(RDBMS).
RDBMS is system used for the management of the database.D<span>ata is stored in the form of related tables.</span>
3 0
4 years ago
Other questions:
  • Add the function min as an abstract function to the class arrayListType to return the smallest element of the list. Also, write
    15·1 answer
  • ____ port is a connection in which eight data lines transmit an entire byte of data at one moment in time.
    12·1 answer
  • bad word bad word bad word bad wordbad word bad wordbad word bad wordbad word bad wordbad word bad wordbad word bad wordbad word
    5·1 answer
  • While these two approaches have similarities in terms of the topics they address, ________ will cover broad IT management topics
    7·1 answer
  • Which of the following conditions will maximize the amount of interest you earn
    5·1 answer
  • An oligopoly is a unique market structure. Which of the following is NOT necessary to have a oligopolistic market structure?
    10·1 answer
  • Click this link to view O*NET's Skills section for Biomedical Engineers. Note that common skills are listed toward the top and l
    8·2 answers
  • Tulio is editing his video. He used the Trim Video tab. Tulio most likely changed the
    12·1 answer
  • Who invented Satellites? What purpose does it serve? How has it impacted society today?
    11·2 answers
  • Which arcade game, released in 1972, is considered to be the first to be commercially successful?.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!