Advertisement
You will write a Java function that performs a complex calcu.pdf
Upcoming SlideShare
Objective In this lab assignment you will write a Java func.pdfObjective In this lab assignment you will write a Java func.pdf
Loading in ... 3
1 of 1
Advertisement

More Related Content

More from fastnews24x7(20)

Advertisement

You will write a Java function that performs a complex calcu.pdf

  1. You will write a Java function that performs a complex calculation with six input parameters. The function should use assertions to check for any errors or inconsistencies in the input data. In addition, the function should handle errors gracefully by substituting the closest legal value or logging a warning message to a file. 1. Create a new Java project in your IDE of choice. 2. Create a new Java class called Calculator with a single static function called complexCalculation that takes six parameters: An integer x A double y A boolean flag A string str An array of integers arr An array of doubles doublesArr 3. Implement the complexCalculation function to perform a complex calculation using the input parameters. 4. Use assertions to check for any errors or inconsistencies in the input data. For example, assert that x is greater than or equal to zero, assert that y is not NaN or infinite, and assert that str is not null or empty. 5. Handle errors gracefully by substituting the closest legal value or logging a warning message to a file. For example, if flag is false, substitute the value of x with the next piece of valid data (i.e., x+1). If arr is null or empty, substitute it with a default array containing the value 0. If doublesArr contains any NaN or infinite values, log a warning message to a file and substitute those values with the closest legal value (i.e., Double.MAX_VALUE or Double.MIN_VALUE). 6. Test your complexCalculation function with various input values, including edge cases and invalid data, to ensure that it works correctly and handles errors and assertions properly. Urgent please
Advertisement