How to write a program in java that ask the user for an input word(use the String method toUpperCase to convert the word to all upper-case characters), then have the program keep looping, generating random strings until the random string matches the user word and keep track of how many loops were required to match. Each time through the loop, your program should output the user’s word, the random string, and the difference score. The difference score is the sum of the absolute value of the difference between each character in the random string and the user’s input string. For example, if the random string was “ABC” and the target string was “AAA”, then the difference score is 3 (abs(A-A) + abs(A-B) + abs(A-C) = 0 + 1 + 2 = 3). You can get at the characters of a string, using the String charAt and absolute value is the abs method of the java.lang.Math class. To generate random strings, in a loop, generate random characters to build up a random string the same length as the user word. To generate a random character make a string of the alphabet String alpha = “ABCDEFGHIJKLMNOPQRSTUVWXYZ”; then generate a random index into that string (use util.Random.nextInt method limited to generating values between 0 and 25 and use the concatenation operator (+) to add the random character to the random string you are building).
output should look simiar to screenshot
Process by which instructions are given to a computer, software program, or application using code.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.