Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

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

enter the word:A
try #0 word=A, randomWord=0, score =14
try #1 word=A, randomword=T, score =19
try #2 word=A, randomword=G, score =6
try #3 word=A, randomword=V, score =21
try #4 word=A, randomword=K, score =10
try #5 word=A, randomword=C, score =2
try #6 word=A, randomword=L, score =11
try #7 word=A, randomword=R, score =17
try #8 word=A, randomword3DV, score =21
try #9 word=A, randomword=D0, score =14
try #10 word=DA, randomword=L, score =11
try #11 word=A, randomword=X, score =23
try #12 word=A, randomword=I, score =8
try #13 word=A, randomword=B, score =1
try #14 word=A, randomword=X, score =23
try #15 word=A, randomword=A, score =0
expand button
Transcribed Image Text:enter the word:A try #0 word=A, randomWord=0, score =14 try #1 word=A, randomword=T, score =19 try #2 word=A, randomword=G, score =6 try #3 word=A, randomword=V, score =21 try #4 word=A, randomword=K, score =10 try #5 word=A, randomword=C, score =2 try #6 word=A, randomword=L, score =11 try #7 word=A, randomword=R, score =17 try #8 word=A, randomword3DV, score =21 try #9 word=A, randomword=D0, score =14 try #10 word=DA, randomword=L, score =11 try #11 word=A, randomword=X, score =23 try #12 word=A, randomword=I, score =8 try #13 word=A, randomword=B, score =1 try #14 word=A, randomword=X, score =23 try #15 word=A, randomword=A, score =0
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
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.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education