Write tha java code for following program(word game) A player (user) is playing a game of words with

Write tha java code for following program(word game) A player (user) is playing a game of words with thecomputer. The computer repeatedly asks a question to the player whoseanswer consists of fixed and known number of letters (characters).The first question has an answer to 4 letters, the second has 5 andfinally the last question’s answer consists of exactly 6 letters.Each question has exactly one unique answer, so the players answerscan be compared with the correct ones stored in the program asString arrays as will be explained later. When a question is presented to the screen, after seeing thequestion the player has two choices: either gives the answer orrequests a letter of the answer. Example: – some possible scenarios for a question whose answeris “table” (having fife letters) Question to be displayed to the player (with an answer of 5letters): Scenario i: A furniture sits around for eating or studying? Enter the answer 1 or request a letter 2: 1 ENTER table ENTER Correct you gained 500 points Scenario ii A furniture sits around for eating or studying? Enter the answer 1 or request a letter 2: 1 ENTER chair ENTER Wrong you lost 500 points Scenario iii A furniture sits around for eating or studying? Enter the answer 1 or request a letter 2: 2 ENTER *a*** Enter the answer 1 or request a letter 2: 2 ENTER *ab** Enter the answer 1 or request a letter 2: 1 ENTER table Correct you gained 300 points Scenario iv A furniture sits around for eating or studying Enter the answer 1 or request a letter 2: 2 ENTER **b** Enter the answer 1 or request a letter 1: 1 ENTER board Wrong you lost 400 points If the player gives an answer and it is correct she will gain(letters-numberOfLettersRequested)*100 points. If the answer iswrong she will lose (letters-numberOfLettersRequested)*100 pointsHere letter is the number of characters of the answer andnumberOfLetersRequest is the total number of letters requested bythe user before giving her answer for this question. In the above example letter is 5 (as the answer of the questionhas 5 letters world – “table”) In scenario i) at the first time without requesting a letter theuser gives the correct answer (table) hence numberOfLettersRequestis 0, she gains (5-0)*100 = 500 points (her accumulated pints isincreased by 500) In scenario ii) at the first time without requesting a letterthe user gives the answer “chair” which is wrong hence(numberOfLettersReq is 0) she loses (5-0)*100 = 500 points (heraccumulated pints is decreased by 500) In scenario iii) at the first time the user requests a letter (arandomly selected letter of “table” in this case its second letter‘a’ is presented “*a***”) hence (numberOfLettersReq becomes 1) thenthe player requests a letter again (a second letter of the correctanswer – in this case the third letter ‘b’ is presented togetherwith the ‘a’ – “*ab**”) so numberOfLettersReq becomes 2 afterseeing “*ab**” the user gives the correct answer she gains(5-2)*100 = 300 points. In scenario iv) at the first time the user requests a letter (arandomly selected letter of “table” in this case its third letter‘b’ is presented – “**b**”) hence (numberOfLettersReq is 1) thenthe user gives the answer but it is incorrect so numberOfLettersReqis still 1, she loses (5-1) *100 = 400 points. The player is asked 3 questions whose answers consisting ofletters ranging from 4 to 6 respectively and at the end of the gametotal score of the player is printed to the screen. (if the playerknows each question without asking any letter she gains 400+500+600= 1500 points) In your program there are three questions with answers having xletters (x ranging from 4 to 6). At each iteration a randomselection is made from these three questions For example when x = 5there are three questions each represented as a String all haveanswers with 5 letters say: “table”, “chair”, flush” only one ofwhich is randomly selected by the program and asked to the user asquestion whose answer is a world with 5 characters. When the user requests a letter a randomly chosen letter fromthe answer is selected and the letter with its position ispresented to the user. If a second letter is demanded the first andthe second and their positions are shown for the missing ones areshown as ‘*’ character is displayed examples “*a***’,’t*b**”) In your program represent questions and their correspondinganswers as two distinct tow-dimensional arrays of Strings. Theith index of the inner array represents ithquestion (whose answer has i+4 letters) and its correct answerrespectively. The jth element of the outer array is one of thethree questions for a letter of i (and naturally their answers).Hold the answer of the player in a string and in deciding whetherit is correct or not make a string comparison. Use Random orSecureRandom class nextInt method for generating random number. After asking 3 questions whose answers are words from 4 to 6letters, calculate and display overall score of the user to thescreen. This means you have to prepare 3*(6-4+1) = 3*3=9 questionsanswer pairs. (3 questions whose answer is a 4-character world, 3questions whose answer is a 5 character world and so on. Storethese questions and answers as two-dimensional String arrays. Andfor each character ranging from 4 to 6 ask only one of them to theplayer. Use loops for iterating over questions from 4 to 6 as the numberof questions asked might be increased in future versions of thegame. Define and initialize the String arrays (question and answerarrays) as class or field variables Use top down software development as much as possible.Preferentially your program should have methods other thanmain. A player (user) is playing a game of words with thecomputer. The computer repeatedly asks a question to the player whoseanswer consists of fixed and known number of letters (characters).The first question has an answer of 4 letters, the second has 5 andfinally the last question’s answer consists of exactly 6 letters.Each question has exactly one unique answer, so the players answerscan be compared with the correct ones stored in the program asString arrays as will be explained later. When a question is presented to the screen, after seeing thequestion the player has two choices: either gives the answer orrequests a letter of the answer. Example: – some possible scenarios for a question whose answeris “table” (having fife letters) Question to be displayed to the player (with an answer of 5letters): Scenario i: A furniture sits around for eating or studying? Enter the answer 1 or request a letter 2: 1 ENTER table ENTER Correct you gained 500 points Scenario ii A furniture sits around for eating or studying? Enter the answer 1 or request a letter 2: 1 ENTER chair ENTER Wrong you lost 500 points Scenario iii A furniture sits around for eating or studying? Enter the answer 1 or request a letter 2: 2 ENTER *a*** Enter the answer 1 or request a letter 2: 2 ENTER *ab** Enter the answer 1 or request a letter 2: 1 ENTER table Correct you gained 300 points Scenario iv A furniture sits around for eating or studying Enter the answer 1 or request a letter 2: 2 ENTER **b** Enter the answer 1 or request a letter 1: 1 ENTER board Wrong you lost 400 points If the player gives an answer and it is correct she will gain(letters-numberOfLettersRequested)*100 points. If the answer iswrong she will lose (letters-numberOfLettersRequested)*100 pointsHere letter is the number of characters of the answer andnumberOfLetersRequest is the total number of letters requested bythe user before giving her answer for this question. In the above example letter is 5 (as the answer of the questionhas 5 letters world – “table”) In scenario i) at the first time without requesting a letter theuser gives the correct answer (table) hence numberOfLettersRequestis 0, she gains (5-0)*100 = 500 points (her accumulated pints isincreased by 500) In scenario ii) at the first time without requesting a letterthe user gives the answer “chair” which is wrong hence(numberOfLettersReq is 0) she loses (5-0)*100 = 500 points (heraccumulated pints is decreased by 500) In scenario iii) at the first time the user requests a letter (arandomly selected letter of “table” in this case its second letter‘a’ is presented “*a***”) hence (numberOfLettersReq becomes 1) thenthe player requests a letter again (a second letter of the correctanswer – in this case the third letter ‘b’ is presented togetherwith the ‘a’ – “*ab**”) so numberOfLettersReq becomes 2 afterseeing “*ab**” the user gives the correct answer she gains(5-2)*100 = 300 points. In scenario iv) at the first time the user requests a letter (arandomly selected letter of “table” in this case its third letter‘b’ is presented – “**b**”) hence (numberOfLettersReq is 1) thenthe user gives the answer but it is incorrect so numberOfLettersReqis still 1, she loses (5-1) *100 = 400 points. The player is asked 3 questions whose answers consisting ofletters ranging from 4 to 6 respectively and at the end of the gametotal score of the player is printed to the screen. (if the playerknows each question without asking any letter she gains 400+500+600= 1500 points) In your program there are three questions with answers having xletters (x ranging from 4 to 6). At each iteration a randomselection is made from these three questions For example when x = 5there are three questions each represented as a String all haveanswers with 5 letters say: “table”, “chair”, flush” only one ofwhich is randomly selected by the program and asked to the user asquestion whose answer is a world with 5 characters. When the user requests a letter a randomly chosen letter fromthe answer is selected and the letter with its position ispresented to the user. If a second letter is demanded the first andthe second and their positions are shown for the missing ones areshown as ‘*’ character is displayed examples “*a***’,’t*b**”) In your program represent questions and their correspondinganswers as two distinct tow-dimensional arrays of Strings. Theith index of the inner array represents ithquestion (whose answer has i+4 letters) and its correct answerrespectively. The jth element of the outer array is one of thethree questions for a letter of i (and naturally their answers).Hold the answer of the player in a string and in deciding whetherit is correct or not make a string comparison. Use Random orSecureRandom class nextInt method for generating random number. After asking 3 questions whose answers are words from 4 to 6letters, calculate and display overall score of the user to thescreen. This means you have to prepare 3*(6-4+1) = 3*3=9 questionsanswer pairs. (3 questions whose answer is a 4-character world, 3questions whose answer is a 5 character world and so on. Storethese questions and answers as two-dimensional String arrays. Andfor each character ranging from 4 to 6 ask only one of them to theplayer. Use loops for iterating over questions from 4 to 6 as the numberof questions asked might be increased in future versions of thegame. Define and initialize the String arrays (question and answerarrays) as class or field variables Use top down software development as much as possible.Preferentially your program should have methods other thanmain. . . .

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Click Here to Make an Order Click Here to Hire a Writer