Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can anyone help me fix my code!!! /** * * @param row1 * @param column1 * @param row2 * @param column2 * @return average of

Can anyone help me fix my code!!!

/**

*

* @param row1

* @param column1

* @param row2

* @param column2

* @return average of values of all DataEntry objects in given address range

* ((row1, column1) to (row2, column2))

* return 0 if there are no items in the given range

*/

public double average(int row1, int column1, int row2, int column2) {

double sum = 0;

int count = 0;

for(DataEntry dataEntry : data)

{

if(dataEntry.inRange(row1, column1, row2, column2))

{

sum += dataEntry.getValue();

count++;

}

} return sum / count;

}

@Test @Graded(description="Worksheet:average()", marks=4)

public void testAverage() {

assertEquals(4.5/8,sheet.average(0, 0, 6, 6), 0.01);

assertEquals(2.6/6,sheet.average(0, 0, 5, 6), 0.01); //without the 0 and 1.9

assertEquals(4.6/7,sheet.average(0, 0, 6, 4), 0.01); //without the -0.1

assertEquals(-4.7/2,sheet.average(0, 3, 5, 3), 0.01); //4th column only

assertEquals(0.4/2,sheet.average(4, 1, 4, 10), 0.01); //5th row only

assertEquals(0,sheet.average(3, 0, 3, 10), 0.01); //4th row only - nothing there

int mark = 4;

marks+=mark;

message+="Worksheet:average() passed. Marks awarded: "+mark+" ";

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions

Question

Why is a square watermelon an advantage?

Answered: 1 week ago

Question

In Exercise 40 what is the

Answered: 1 week ago

Question

Define induction and what are its objectives ?

Answered: 1 week ago

Question

Discuss the techniques of job analysis.

Answered: 1 week ago

Question

How do we do subnetting in IPv6?Explain with a suitable example.

Answered: 1 week ago

Question

Explain the guideline for job description.

Answered: 1 week ago

Question

What is job description ? State the uses of job description.

Answered: 1 week ago