Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

During a drought, each household in a village is restricted to a certain limit of liters of water. The current water usage of each household

During a drought, each household in a village is restricted to a certain limit of liters of water. The current water usage of each household is tracked and stored in a list.
For example, the current usage for 5 households could be represented in the following array:
[3.5,8.5,10,0,20]
(the first has used 3.5 liters, the second 8.5 liters, etc.).
Write a method/function to determine the remaining amount of water each household is allowed to use and returns a new list containing these figures. If a household has already reached or exceeded the limit, the they are not allowed any more water. For the example above for a limit of 10.0 liters, the method/function should return a list containing the following values.
[6.5,1.5,0.0,10.0,0.0]
The 3rd and 5th households have met and exceeded the limit respectively and have 0 remaining liters available.
Rainfall Map
Rainfall monitors from the Airbender tribe take regular measurements of rainfall in an area represented by a two dimensional n x m grid and store it as a 2 dimensional array/list. For example, consider the following 3x5 map:
[0.75,0.50,0.00,-1.00,0.10]
[1.00,0.25,0.125,0.00,-5.0]
[1.25,0.50,-1.0,0.10,2.75]
When data is not available a negative value is used. In this example 3 of the data points are negative so we ignore them.
Write the a method/function that takes a map and returns the average rainfall. In the example above, 12 data points are valid and sum to 7.325 for an average of 7.325/12=0.610 units of rain (the actual units are irrelevant).
Instructions & Unit Testing
For the Java version, we have provided a starter file with specific method signatures. We have also provided a JUnit starter file that has several test cases already written. In addition to implementing all methods as specified, you will be required to add additional test cases to the JUnit testing suite. Specifically, you need to add at least 2 valid test cases for each method you need to implement.
For the Python version, we have provided a starter file with specific function signatures. We have also provided a unittest starter file that has several test cases already written. In addition to implementing all function as specified, you will be required to add additional test cases to the unittest testing suite. Specifically, you need to add at least 2 valid test cases for each function you need to implement.
can you help me the code this I cant figure this out I got the starter code for this with functions
package unl.soc;
import java.util.List;
/**
* TODO: author, date and class documentation
*
*/
public class WaterUtils {
/**
* TODO: documentation
*
* @param limit
* @param usage
* @return
*/
public static List getRemainingWater(double limit, List usage){
return null;
}
/**
* TODO: documentation
*
* @param map
* @return
*/
public static double averageRainfall(double map[][]){
return -1.0;
}
}

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

Intelligent Information And Database Systems 12th Asian Conference ACIIDS 2020 Phuket Thailand March 23 26 2020 Proceedings

Authors: Pawel Sitek ,Marcin Pietranik ,Marek Krotkiewicz ,Chutimet Srinilta

1st Edition

9811533792, 978-9811533792

More Books

Students also viewed these Databases questions

Question

3 x 2 + 5 x + 1 = 0

Answered: 1 week ago

Question

Describe the linkages between HRM and strategy formulation. page 74

Answered: 1 week ago

Question

Identify approaches to improving retention rates.

Answered: 1 week ago