Question: URGENT PLEASE! (Java) Suppose the weight of a string is defined as the fraction of the string that's made of non- digit characters (i.e.,
URGENT PLEASE! (Java) Suppose the " weight" of a string is defined as the fraction of the string that's made of non- digit characters (i.e., any character besides 0-9). For example, the weight of the string " exAmpLe19!" is 0.8 since 8 out of its 10 characters are not digits. The empty string is considered to have a weight of . Write the static method averageWeight( Stringstuff )This method should return the average weight of the strings within the array stuff. Any null elements of stuff should be excluded from the average (i.e., the null elements should not be included in either the numerator or the denominator of the average). If stuff has a length of ( which is totally possible in Java), or if stuff has a non-zero length but has all null elements, the method should return 0.0 . Use only the following String methods in your solution: charAt, equals, indexOf length, split substring, to LowerCase , toUpperCase . Be sure to include the full method headerDo not include the class or main method.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
