Computers and Technology
Computers and Technology, 11.02.2021 22:10, chloe4740

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 )

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 07:00, yyy77uh
You will be given two character arrays of the same size, one will contain a number of ships. ships will move around the character array based on which way they are facing and the route they are on. routes are given in the other array. the route consists of '-' and '|' for straight paths, '\' and '/' for curves, and '+' for intersections. there are ships on these routes. ships always face a direction, '^' for up, '> ' for right, 'v' for down, and '< ' for left. any time the ships hit a '\' or a '/' it will turn as you would expect a ship to turn (e. g. a '^' that moves into a '/' will turn right). at an intersection, ships will always continue straight through. all ships move at the same speed, ships take turns moving and all ships move during one 'tick'. the one in the most top left goes first, followed by those to its right, then the ones in the next row. it iterates along the rows and then down the columns. each ship moves one space on its turn moving along the route. your function needs to return the position of the first collision between two ships and the number of ticks before the crash occurred.
Answers: 2
image
Computers and Technology, 23.06.2019 11:30, leapfroggiez
Auser is given read permission to a file stored on an ntfs-formatted volume. the file is then copied to a folder on the same ntfs-formatted volume where the user has been given full control permission for that folder. when the user logs on to the computer holding the file and accesses its new location via a drive letter, what is the user's effective permission to the file? a. read b. full control c. no access d. modify e. none of the above
Answers: 1
image
Computers and Technology, 24.06.2019 00:00, miguelturner
Which tool could be used to display only rows containing presidents who served two terms
Answers: 3
image
Computers and Technology, 24.06.2019 15:30, taylorpayne525p8qxky
What is not a type of text format that will automatically be converted by outlook into a hyperlink?
Answers: 1
Do you know the correct answer?
Complete the constructor in the following program so that it constructs the array data, then copies...

Questions in other subjects:

Konu
Business, 19.05.2020 13:05