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
Wittaler [7]
3 years ago
7

Write a method called mode that returns the most frequently occurring element of an * array of integers. Assume that the array h

as at least one element and that every element * in the array has a value between 0 and 100 inclusive. Break ties by choosing the lower * value. */
Computers and Technology
1 answer:
labwork [276]3 years ago
8 0

Answer:

The method definition to this question can be given as:

Method definition:

public static int mode(int[] a1) //define method mode.

{

int[] a = new int[101]; //define array.

int i,mode =101,counts = 0; ; //define variable.

for (i = 0; i <a1.length; i++) //loop  

{

a[a1[i]]++; //increasing value.

}

for (i = 0; i <a.length; i++)//loop  

{

if (a[i]>counts)//if block

{

counts=a[i]; //variable holds array value.

mode = i; //variable holds i value.

}

}

return mode;

}

Explanation:

The description of the above method as follows:  

  • Firstly we define a method that is "mode" in this method we pass an integer array that is "a1[]" and the method returns an integer value because its return type is "integer".  
  • Inside a method, we define another array and variables that are "a[], mode, i, and counts". array variables collect the parameter passed the array and check the lowest value element in the array. To check this condition we use these variables and conditional statements.  
  • Then we define a loop inside the loop use conditional statement in the if block we check array element value is grater than counts if this condition is true so, counts variable value is changed by array value and mode variable holds loop variable (i)value and return mode value.
You might be interested in
At one college, the tuition for a full-time student is $6,000 per semester. It has been announced that the tuition will increase
Alina [70]

Answer:

  1. var projected_fee = 6000;  
  2. for(var i = 1; i <= 5; i++){
  3.    projected_fee = projected_fee * 0.02 + projected_fee;
  4.    console.log("$" + projected_fee.toFixed(2));
  5. }

Explanation:

Firstly, create a variable, projected_fee, and set the initial tuition fee value to it (Line 1).

Next, user a for loop that run for 5 times to repeatedly calculate the projected_fee based on 2 percent of increment rate (Line 4) and display the projected fee to console terminal (Line 5). The output should be

$6120.00

$6242.40

$6367.25

$6494.59

$6624.48

8 0
3 years ago
Help me right now!!!!!!!!!!!!!!!!!!!!!!!!11
PilotLPTM [1.2K]
Word-processing software includes basic applications designed for casual business or home users and powerful, advanced applications capable of meeting the most-demanding needs of businesses. Many word-processing applications are designed for use as part of a suite or integrated group of word-processing, spreadsheet, and presentation programs
4 0
3 years ago
Who is better at fortnite mc creamy or mau?
Mama L [17]

Answer:

neither

Explanation:

fortnite sucks

8 0
3 years ago
Read 2 more answers
Set-In-Order includes making changes to the layout of the area.A) TrueB) False
Bogdan [553]

Answer:

A) True

Explanation:

Set-In-Order is part of a 5S system approach of making a workplace to be well arranged so there will be smooth operation of employees and working conditions.

Set-In-Order specifically deals with entities in the workplace apparently labeled after being well arranged in their respective places.

Hence, it is TRUE that Set-In-Order includes making changes to the layout of the area.

7 0
3 years ago
Which Operating System is used most often in households?
pshichka [43]

Answer:

Windows

Explanation:

Windows are one of the most popular household os.

3 0
3 years ago
Read 2 more answers
Other questions:
  • 9. The best way to insert an existing Excel chart into a document is to A. use the Object command. B. click the Insert tab and c
    6·2 answers
  • Select all that apply. Given the following code fragment, which of the things shown below happen when the statement on line 8 ex
    13·1 answer
  • The master system database stores a database template that is used as a blueprint when creating a new user database.
    10·1 answer
  • Enter the answer.
    11·2 answers
  • The main screen of wireshark includes several shortcuts. which shortcut category displays a list of the network interfaces, or m
    15·1 answer
  • History timeline: who developed what elements first Windows OS and Apple OS?
    13·2 answers
  • Data are sent through a network on bundles called _______. select one:
    8·2 answers
  • What is TCP/IP adress​
    10·1 answer
  • Which coding term means to carry out a series of steps one after another?
    7·2 answers
  • HURRY please!!!!
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!