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
Explain why much of social media marketing is trial and error.
Ivahew [28]
The first thing that entrepreneurs need to realize is that the process and framework for making social media marketing work are different from traditional marketing, and trial and error certainly doesn’t work. Ric Dragon, an expert in online marketing, in his new book “Social Marketology<span>,” outlined the best set of steps I have seen so far for the new world:</span>
7 0
3 years ago
Type the correct answer in the box. Spell all words correctly. How is it possible to access data from any location? Storing data
romanna [79]

Answer:

optical

Explanation:

The earliest of these was the magnetic device. Computer systems began with magnetic storage in the form of tapes (yes, just like a cassette or video tape). These graduated to the hard disk drive and then to a floppy disk.

5 0
3 years ago
Which of the following are actions a programmer could take when debugging a segment of code that would most likely lead to findi
Verizon [17]

Answer:

Option B and C are the correct answer for the above question

Explanation:

The above question asked about the work of the programmer to catch an error of the program--

  • Then the option B states that the programmer needs to prints the value of the various program variable on every line of the program which is the correct solution because it is used to find the error easily. It defines the value of every variable in every place of the program and the programmer caught the error statement in the program if anywhere the variable gets the false value.
  • The C option states to help from a friend, it is also a good solution because the friend can easily be caught the error of the program by seeing every line of code.
  • But the other option is not correct because the option A states that the change the name of the variable which is not a result of anything.
  • And the option D states that the code will be retyped again which is also not justify anything.

6 0
3 years ago
If an engine has four cylinders and a total of 16 valves, how many valves would each cylinder have?
wel
4 because 4 x 4=16. Easy. I like to think of it as multiplication.
4 0
3 years ago
Under which menu option of a word processing program does a star
12345 [234]

Answer:

<u><em>A callout is a type of text box that also includes a line for pointing to any location on the document. A callout appears under the SHAPES menu of the word processing program. The answer that completes this statement is the word "shapes". Hope this answers your question. </em></u>

<u><em></em></u>

Explanation:

8 0
3 years ago
Other questions:
  • A half-life is the amount of time it takes for a substance or entity to fall to half its original value. Caffeine has a half-lif
    10·1 answer
  • Consider what fact-finding techniques you would use to identify the important facts needed to develop a database system. Please
    7·1 answer
  • Which cisco ios command is used to display the current ospf neighbors and their rids?
    11·1 answer
  • An is auditor reviewing a network log discovers that an employee ran elevated commands on his/her pc by invoking the task schedu
    10·1 answer
  • What country threatens Denmark at the beginning of Hamlet as evidenced in Marcellus’s question, "Why this same strict and most o
    13·1 answer
  • How do I take this prodram back off
    15·1 answer
  • RAM memory is intended?
    8·1 answer
  • The illustration shows different types of text language.
    5·2 answers
  • What is the output?
    11·1 answer
  • Answer the following 8-mark question in your book.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!