subject

Complete the constructor in the following program so that it constructs the array data, then copies values from the parameter init into data. Then complete the toString() method.

class Weight
{
private int[] data;

// Constructor
public Weight(int[] init)
{
// Make data the same length
// as the array referenced by init.
data = new

// Copy values from the
// input data to data.
for (int j)
{
data[j] =
}
}

//Print
public String toString()
{

}
}

public class WeightTester
{
public static void main ( String[] args )
{
int[] values = { 98, 99, 98, 99, 100, 101, 102, 100, 104, 105,
105, 106, 105, 103, 104, 103, 105, 106, 107, 106,
105, 105, 104, 104, 103, 102, 102, 101, 100, 102};
Weight june = new Weight( values );
System. out. println( june );
}
}
2.

class Weight
{
. . .

public int average()
{
. . .
}
}

public class WeightTester
{
public static void main ( String[] args )
{
int[] values = { 98, 99, 98, 99, 100, 101, 102, 100, 104, 105,
105, 106, 105, 103, 104, 103, 105, 106, 107, 106,
105, 105, 104, 104, 103, 102, 102, 101, 100, 102};

Weight june = new Weight( values );
int avg = june. average();
System. out. println("average = " + avg );
}
}

Now add another method that computes the average for a range of days. The method header looks like this:

public int subAverage( int start, int end )

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:30
The qwerty keyboard is the most common layout of keys on a keyboard
Answers: 3
question
Computers and Technology, 23.06.2019 21:40
language consists of basic components, and they are called a. 3; mental images, concepts, and speech b. 2; language acquisition and linguistic relativity c. 3; heuristics, algorithms, and analogies d. 4; phonemes, morphemes, syntax, and semantics e. 2; words and grammar
Answers: 3
question
Computers and Technology, 24.06.2019 13:30
What is the most important for you to choose before you build a network?
Answers: 1
question
Computers and Technology, 24.06.2019 19:00
Luis is cloud-based( microsoft bot framework). true false
Answers: 1
You know the right answer?
Complete the constructor in the following program so that it constructs the array data, then copies...
Questions
question
Mathematics, 16.01.2020 13:31
question
Mathematics, 16.01.2020 13:31
Questions on the website: 13722361