Question: Declare a String variable called name and set this equal to testname Ask the user to enter their full name and read this into another
Declare a String variable called name and set this equal to "testname" Ask the user to enter their full name and read this into another string . Check if the length of the string is greater than 8 characters, if so create a substring that contains only the first 8 characters from the string, otherwise leave the input as it is Convert this new substring into all lowercase using built in methods of the String class Check whether the string name is equal to this string entered from the user (if the string was longer than 8 characters use the substring to check) - use the built in methods of String class to check Calculate the average length of both strings (length of (string1 + string2/2). You can calculate the length of the strings by using the length() method from the String class. Then using built in methods from the Math class round the average down to the nearest integer (you can do this step in the same line as the step above or in different lines - choice is yours) o If the avg length is less than 8 concatenate both strings together (make sure you add a whitespace to separate both strings) If the avg length is greater than or equal to 8 concatenate simply print "Average length of both strings is greater than or equal to 8)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
