Question: package console_apps; import java.util.Scanner; import model.Utilities; public class GetIntermediateStatsApp { public static void main(String[] args) { Scanner input = new Scanner(System.in); /* Prompt the user
2.2.2 Method to Implement: getIntermediateStats Problem. You are asked to implement a utility method which takes w inputs the first term (4), common difference (d), and size (1) of an arithmetic sequence. Based on these three input values, the corresponding arithmetic sequence (of n terme) is: (41. ta, si ....) where t = ft + (1 - 1).d and 1 Sisn The utility method should return a string value containing the following equal-sized sequence of statistical iteit where each statistical item (ISIS) reports the sum and average of the subsequence (.....) (of sizei). For example, the statistical item as reports the sun and average of the subsequence (h. 1. 6) (which, of course, is just a smaller arithmetic sequence). Requirement. It is strictly forbidden for you to use array of my library class (0.8., Arraytist). Violating this requirement will cause a 50% penalty on your lab marks. Testing Your goal is to pass all tests related to this method in the JUnit test class Testutilities. These tests document the expected values on various cruses: study them while developing your code. However, the main application eines Get IntermediateStatsApp if you wish (ng the input and experter values from the JUnit tests). Here is an example ran Enter the first integer term of an arithmetic sequence: 23 Enter the common difference of the sequence: 11 Enter the size of the sequence: 2 [sun of : 23 : avg of : 23.00). (sum of : 28.50]} Todo. Implement the Utilities.getIntermediatestats method. See the comments there for the input parasti eters and requirements. The String return value must conform to the expected format: All statistical terms are wrapped within curly braces (0) and separated by cotnmas (.). Each statistical term is wrapped within square brackets (C) and reports the sum and average of the corte- sponding sub-subsequence. Each sum is an integer and each average should be formatted as a floating-point number with 2 digits after the decimal point, using String.format(X.2f, someNumber). . In the above example, the arithmetic sequence implied by the three input value (23, 11 and 2) Is (23, 34), and the output string contains the statistical items for the two sub-sequences (23) and (23, 34). . As a slightly longer example, consider the statistical terms that should be included in the output string by input values 23 (first term), 11 common difference), and 5 (size): [sum of : 23 : avg of : 23.09) [sum of : 102 ; avg of 23, 34, 45): 34.00) [sum of : 158 : avg of 23, 34, 45, 56): 39.50) [sum of : 45.60) All five statistical items above should be wrapped within curly braces ((!) and separated by comumas (). . There is one space before and after the semicolon (:). There is one space after each comma (.) and colon (:)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
