Question
Done in Java. Any help appreciated! 2: Min-Max Strings Find the minimum and maximum values of an ArrayList of Integers , which was generated using
Done in Java. Any help appreciated!
2: Min-Max Strings
Find the minimum and maximum values of an ArrayList of Integers, which was generated using an ArrayList of Strings.
Implementation Details:
1. Take the size of the list N and list of N strings as the user input using Scanner. (Alternatively, you can write a Random String Generator method for a given N)
2. Store these N strings in an ArrayList.
3. Now, for each string in this ArrayList, calculate the sum of ASCII values of all the characters in that String and store that sum in an anotherArrayList.
4. Now, find the minimum and maximum values from thisArrayList.
5. Store those 2 values in an Array in the following order {minValue, maxValue} and return thisArray.
6. Also, write JUnit tests.
Examples:
Input: N = 3
myArrayList = {John, Nick, Alex}
sumArrayList = {399 , 389 , 394}
Output: [389,399]
SumArrayList calculation - > J ( 74 ) + o ( 111 ) + h ( 104 )+ n ( 110 ) = 399 ,
Similarly, calculate sum for other strings.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started