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
astraxan [27]
3 years ago
8

Please write a Java program.

Computers and Technology
1 answer:
Marianna [84]3 years ago
5 0

Answer:

public class Main

{

public static void main(String[] args) {

 int[] arr = {3, 1, 1, 2, 4, 4, 4, 6};

 

 int[] o = countOccurance(arr);

 for (int x: o)

     System.out.print(x + " ");

}

public static int[] countOccurance(int[] arr){

    int[] occ = new int[6];

    for (int x: arr)

        occ[x-1]++;

   

    return occ;

}

}

Explanation:

Create a function called countOccurance that takes one parameter, an array

Inside the function, initialize an array, occ, to hold the occurance counts

Create a for each loop to iterate the array, and increment the occurance of the numbers

When the loop is done, return the occ array

Inside the main, initialize an array

Call the function countOccurance and set it to a new array, o

Print the elements of the o to see the number of occurances of the numbers

You might be interested in
Communication is the transmission of messages to large audiences.
masha68 [24]
Communication doesn't necessarily mean you're communicating to a large audience. So that is false.
3 0
3 years ago
A ___________ is the smallest unit in a written language.
Delvig [45]
A. string? maybee its a string of units


8 0
3 years ago
Read 2 more answers
Define operating system?explain the types of operating system on the basis of use.​
GalinKa [24]

Answer:

An operating system is a software that helps the any computers basic needs or functions.  For example, the windows on a computer is a operating system.

Explanation:

4 0
2 years ago
Under what conditions might the Justice Department approve a merger between two companies that operate in an industry with a pos
pogonyaev

Answer:

Explanation:

Overall an industry with a post merger Herfindahl-Hirschman index value of below 1500 is considered un-concentrated.In an extreme case,if the Herfindahl-Hirschman index in an industry exceeds 2900,it suggest that the industry is highly concentrated.

In that case if a merger is going to occur which is expected to raise the Herfindahl-Hirschman index by 255 points,then the FTC and DOJ might challenge a lawsuit against such merger,some other factor are also scrutinized.

This include economies of scale,economies of scopes and the ease in which there is an entry possible in the industry,The agencies like FTC and DOJ try to block horizontal merger if it expected to create unsuitable economic business environment for other firms in the industry

3 0
4 years ago
If you are installing separate anti-virus and anti-spyware programs, which should you install first
Vera_Pavlovna [14]
Probably the anti virus, so you don't get a virus from downloading the anti spyware program.
6 0
3 years ago
Other questions:
  • Interpretations of​ Moore's law assert​ that:
    13·1 answer
  • Why is there a need to compare and align one's PECs of a successful entrepreneur?
    5·1 answer
  • 12. Noodle Tools is a website that
    8·1 answer
  • What is an effective way to assess user requests for additional features and functions
    10·1 answer
  • What is the approximate area of the figure? A. 129 square inches B. 113 square inches C. 110 square inches D. 44 square inches
    15·1 answer
  • What are data structures and algorithms? Why are they important to software developer?
    14·1 answer
  • The working window of a presentation is the O outline O handout 0 notes o slide​
    5·2 answers
  • H e l p ASAP plz <br> and thanks
    9·1 answer
  • Jacob has a text file open, and he is typing on the keyboard. What is the best description of how the
    8·1 answer
  • The function's only behavior should be to return the sum of array userVals' elements. What common error does the function make?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!