Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MultiThreading Hi! I asked this question yesterday and there may have been some change in how Chegg does its answers or viewing of questions, But

MultiThreading

Hi! I asked this question yesterday and there may have been some change in how Chegg does its answers or viewing of questions, But i need the code for the Discover, Reveal, and Expose thread Classes, as well as the driver Code, And if the expert who answered this earlier today is reading, thank you for the response Below the pictures is the contents of the xyz.txt file.

My questions is for Discover, Expose and Revel classes

And thank you to whoever answers this question. image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

**PQLG 4 3 2 7$ *** If you add thirty to ten, then result of fifty three is incorrect$* 18 9 6 0 17 -4 $ **ACDUJF 1 4 6 9$*** Only thirty people injured in DC last week and two died$* -8 10 21 23 10 12$ *** Everybody says two of the three men are guilty$ * -3 35 -18 2 11 6$** KMLN 12 3 4 17$ *25 24 23 22 21 20$*** This is one good example among sixteen of them$ ** AZZA 2 12 1 8$1$

** MNKKLLSGQW 1 2 3 4$ * -12 -2 -4 -8 -1 40$ ***dear friend I hope you are doing well and not thinking about this assignment$ ***Today is a good day for having fun for one day$*70, 1,50, 8, 20, 95$** GSUN 5 8 1 15 $ * 2, 3, 5, 100, 0$ ** MICH 7 8 2 9$ *** This is one good example among sixteen of them$ ***MSU is a nice place for only four years $* LFord 3 2 1 9 $ * 20, 30, 90, 0, 1 -82$ **GG 9 2 1 15$ ***Sixteen plus one is seventeen and minus nine is seven$* 12 15 21 -1 * 12 3 22 3 21 -20$ ***One day when the weather was good one of his friends took her to a movie $ **JOHN 12 15 1 1$

n: Write a Java program that reads one record at a time from the file xyz (shown at the end of the assignment). Each record has three sections (i.e., three character-strings) and the order of the three sections may be different from one record to the next. However, the number of asterisks at the beginning of each section determines the section number. For example, section 2 within the record is prefixed with two asterisks. Each section ends with a $ symbol and neither asterisks nor the $ are a part of the section. Example of a record: PQLG 4327$Ifyouaddthirtytoten,thenresultoffiftythreeisincorrect18960174 The main module separates the three sections and sends sections one, two, and three to the following three threads of Reveal, Expose, and Discover, respectively. For the above record's example, the three sections are : Section two: PQLG 4427 Section three: If you add thirty to twenty, then result of fifty three is incorrect Reveal Thread The message is made up of six integer numbers, The thread computes a value for M as follows: M= (sum of six numbers) mod26. For our example M=[(18)+(9)+(6)+(0)+(17)+(4)]mod26=(46) mode 26=20 Remember that applying mod function on a negative number may produce a nonpredictable number. Therefore, if you have reached to the point that you must apply mod function on a negative number, then the thread needs to be exited and an error message expressing the case needs to be printed. The Reveal thread will: a) replace each integer number with (M - integer number) mod26 For our example the integer numbers of 18960174arereplacedby [2018]mod26=2[209]mod26=11[206]mode26=14 [200]mod26=20)[2017]mod26=3[20(4)]mod26=24 The resulting values are valid if they are integer numbers in the range of [025] b) Each integer number resulting from the above step represents the location of an alphabet character in the English alphabet. For our example, the replacement of integer numbers produced in step (a) resulting in: (You may show the outcome by uppercase or lowercase letters.) In the case that the Reveal thread completes its task successfully, the output for the Reveal thread is: Reveal - Section 1 is: 18960174 - The revealed code is: CLOUDY-valid In the case that the Reveal thread is exited prematurely due to some errors, the output for the Real thread is: Reveal - Section 1 is: 18960174 - Invalid Expose Thread This thread breaks its message into two parts: Part 1 and Part2. Part1 carries the first token of the message and Part 2 carries the rest of the tokens. If any of the following conditions is true, then a proper error message is printed, and Expose thread will be exited: - Part 1 includes characters other than alphabet letters - The number of characters in the Part 1 is not even - The number of tokens in Part 2 is not 4 - The tokens in Part 2 are not integers. For our example: PQLG 4427 Part 1 is: PQLG Part 2 is: 4427 Both Parts are valid. The goal is to decipher the message PQLG. To do so, 1) The thread creates a matrix 21, named C, out of the positions of the first 2 characters of Part 1 in the English alphabet letters. For our example, the first two letters are PQ and their positions in alphabet letters are 15 and 16 , respectively. Therefore, we make the matrix C=[1516] The thread also creates a square matrix of 22, named S, out of the tokens in Part 2 . For our example: S=[4237] The thread calculates the matrix C=(SC)mod(26) The matrix C=S=Cmod26=[4237][1516]mod26=[108142]mod26=[412] Therefore, PQ are deciphered into E and M (the letters located in positions 4 and 12 among the English alphabet letters.) The above process is repeated for the next two characters in Part1 (i.e., LG). Matrix C changes into C=[116] but matrix S remains the same. Since the matrix S is a 22 matrix then, the Part 1 is always deciphered 2 characters at a time. The matrix C=SCmod26=[4237][116]mod26=[6264]mod26=[1012] Therefore, LG are deciphered into K and M (the letters located in positions 10 and 12 among the English alphabet letters.) As a result, the message PQLG is deciphered into EMKM (The message may be deciphered into a set of characters that does not have any meaning to you. That is okay.) In the case that the Expose thread completes its task and decipher the code, the output for the Expose thread is: Expose - Section 2 is: PQLG 4327-Deciphered code is: EMKM-valid In the case that the Expose thread is exited prematurely due to some errors, the output for the Expose thread is: Expose - Section 2 is: PQLG 4327-Invalid Discover Thread This thread receives the character string of Section three as its argument. Section three includes a scrambled password. Discover thread tries to de-scramble the password. The password is always 8 characters long and starts with a lowercase alphabet letter and includes at least one digit and the rest of characters are lowercase alphabet letters. For the example in hand. Section three is: If you add thirty to twenty, then result of fifty three is inconect The password is de-scrambled as follows: 1. All tokens that represent a digit expressed by alphabet letters (e.g., "two" represents digit 2) are replaced by the digit. For the example in hand Section three is : "If you add thinty to twenty, then result of fifty three is incorrect" Using step 1, the section three changes into Section three is : "If you add thinty to twenty, then result of fifty 3 is incorrect" 2. Identify the valid tokens. A valid token starts with a lowercase alphabet letter or a digit. The password is the first character of these tokens and in the order that they appear in the Section three. Using step 2 the valid tokens are shown in red If you add thirty and twenty, result of fifty 3 is inconrect" The preliminary password is: yatatrof 3 ii 3. If the length of the de-scrambled password is longer than eight characters, then the first eight characters make the password unless the truncation produces an invalid password. If this is the case, then the last eight characters make the password. If truncation in both cases generates an invalid password, then the de-scrambled password is considered invalid. The valid and invalid passwords are printed with a proper message indicating the validity/invalidity of the password. Using step 3 the password is: yatatrof This is an invalid password because it does not have any digit in it Therefore, the password is 8 characters from the other end: ii 3 forta // A valid password Discover Thread prints the line of: Discover - Section. 3 is: If you add thirty to twenty, then result of fifty three is inconrect passwd is: ii3forta - valid For the sake of discussion, let us assume that we cannot find a valid password from either end. In this case Discover thread prints the line of: Discover - Section 3 is: If you add thirty to twenty, then result of fifty three is incorrect - passwd is: atrof3ii - invalid Notes: 1. Drop a copy of your program along with the output in the dropbox Assignment-1 in Folio. File xyz You are not permitted to insert space(s) or any other type of delimiters anywhere in the records of the file xyz. *25 24232221205 This is one good example among sixteen of them\$ ** AZZA 21218$ thinking about this assiguments ***Today is a good day for having fun for one day\$*70,1,50,8,20,95\$** GSUN 5 \& 8115$ 2,3,5,100,0$MICH7829$ This is one good example among sixteen of thems * 1232232120 One day when the weather was good one of his friends took her to a movie $ JOHN 121511$

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions

Question

25.0 m C B A 52.0 m 65.0 m

Answered: 1 week ago