GE Assignment COMP8702 | My Assignment Tutor

GE Assignment COMP8702– Semester 1, 2021Math HelperPlease ensure you read and understand the entire document before undertaking this assignment.If you require clarification on the specification within, please seek this as soon as possible.Learning Outcomes• Comprehend basic program control constructs of sequence, selection, and iteration;• Use integrated development environments and tools within a programming and versioncontrol context;• Understand the basics of code management systems;• Translate pseudo-code into a readable, working program;• Apply programming principles to solve domain-specific problems;• Apply your knowledge and skills within the context of professional contributions to adefined information space.Submission and AssessmentThe assignment is comprised of six parts that each will require you to complete a series of steps toconstruct a Java program that adheres to the described specification. Remember to analyse theproblem as necessary and design a solution that suits the deliverables. You need to determinethe structures you will use. This is an application that will reuse elements significantly and assuch your development should consider this. At the conclusion of each task, you will be askedto address several questions and report on the approach you have taken to complete the steps.Treat this as a professional activity, so in-line comments, documentation and application outputshould be presented appropriately for the target audience. Furthermore, your report should bepresented in a manner suitable for a professional audience.Failure to use the supplied code repository will result in zero marks for thisassignment.It is suggested that at a minimum you commit your code, with an appropriate comment, afterthe completion of each task. That way if you do not complete all tasks you still have workingcode for the final submission.You will be awarded marks for the level of completion of your program (including answers tothe questions in each section). This assignment will be marked out of a total of 150 marks asfollows:TASK : MARKSTask 1 : 10Task 2 : 30Task 3 : 20Task 4 : 20Task 5 : 20Task 6 : 30Style (coding conventions and white-space) : 201GE Assignment COMP8702– Semester 1, 2021Development should be consistent with the IntelliJ environment, any issues running a programdeveloped in another IDE will result in a penalty of 50% of your grade.HOW TO submit the code and revision numberOn your final commit to the repository you need to take note of what the revision number i s. Youcan see this in the versioning window in IntelliJ or do a “Subversion → Search History” and seewhat the final commit revision number i s. Once you have that you can submit your assignmentand enter the final r evision n umber a long w ith y our P DF t o t he a ssignment s ubmission boxon FLO. The final r evision number g oes i nto t he O nline t ext e ntry, i n F igure 1 t he revisionnumber is 1234You will need to submit your final revision number and your report as a single PDF documenton FLO by 5pm, Friday 4th June, 2021 (week 12).Figure 1: How to submit your assignment on FLOAcademic IntegrityAs required by Flinders University policy, a report on your submission will be generated bythe TurnItIn text-matching software, which compares your work with a large body of materialand generates a report of any similarities. Each student should carefully ensure that the workthey submit is their own and that any material directly sourced from the work of others isproperly acknowledged. A Drafts hand-in is available on FLO so you can check your workbefore your final submission. Information on academic integrity, including the use of TurnItInand interpreting its reports, is available on the Academic Integrity for Students FLO page.Please familiarise yourself with the policy.2GE Assignment COMP8702– Semester 1, 2021SpecificationYou have been approached by a local education company to provide a software solution to helpstudents at all levels with their mathematics studies. The company requires an applicationthat produces random arithmetic expressions tailored to the level appropriate for the student.This should be an application that is easy to use for students from Reception level to Year 7(5 years old to 12 years old). It should be a text based application that presents an expressionand allows the user to type the answer. The application will confirm if the supplied answer iscorrect or incorrect immediately and also keep track of the overall percentage for the student.This overall percentage is reported at the end of the session with an appropriate statement offeedback. The length of a session should be defined at the start of each session and can include10, 20, 30, 40, or 50 questions. The following issues should be considered at the start of eachsession, addressed by numbered menus:• What is the level of the student?Reception: only additionYears 1 – 2: addition and subtractionYears 3 – 4: addition, subtraction, multiplication, division (without remainder)Years 5 – 6: addition, subtraction, multiplication, division (without remainder), negativenumbersYear 7: addition, subtraction, multiplication, division (without remainder), division (withremainder – presented as xry, where x is the result of the division and y is theremainder, ie 10 % 3 = 3r1), negative numbers• What is the length of the session?– 10 questions– 20 questions– 30 questions– 40 questions– 50 questionsThe year level that the user supplies will determine what number ranges are used. unitsunitstenshundreds(0 → 9)(-9 → 9)(-99 → 99)(-999 → 999)[ At Reception][ From Reception ][ From year 2 ][ From year 4 ]thousands (-9999 → 9999) [ At year 7 ]Example output could be as follows (user input in bold green):+————————————————————————+|||Welcome to the Maths Helper!|||Use this application to test your knowledge of mathematicsThis program is intended for children from reception to year 7 +————————————————————————+What is your year level?Choose an option from the list below:(where: + = addition, – = subtraction, * = multiplication,3GE Assignment COMP8702– Semester 1, 2021/ = division, % = division with remainder)[0] Reception [+][1] Year 1 [+, -][2] Year 2 [+, -][3] Year 3 [+, -, *, /][4] Year 4 [+, -, *, /][5] Year 5 [+, -, *, /, negative numbers][6] Year 6 [+, -, *, /, negative numbers][7] Year 7 [+, -, *, /, %, negative numbers]3How many questions would you like to attempt?Choose an option from the list below:[1] 10 questions[2] 20 questions[3] 30 questions[4] 40 questions[5] 50 questions4You are a year 3 student and want to do 40 questions. Is this correct (Y/N)? YLet’s begin … (press ‘Q’ at any time to quit)If the student indicates that the information entered was incorrect then they should be promptedto re-enter their details. Both menus should be displayed again until the user enters the correctoptions.A standard session will generate a random expression (random numbers and random operator)and output the expression as a string to the terminal window. The application will wait fora user response to the expression and once entered will assess the correctness of the input. Astring indicating the correctness of the student’s answer will be displayed and then the nextexpression generated and displayed. This process will continue until all the questions in thatsession have been answered.Example output could be as follows (user input in bold green):64 + 12 = 76Correct! Well Done! Your current percentage is 100%10 + 97 = 107Correct! Well Done! Your current percentage is 100%5 * 39 = 159Bad luck that was incorrect. The correct answer was 195.Your current percentage is 66.67%22 / 58 = 0Correct! Well Done! Your current percentage is 75%…Your total percentage was 72%. Well done. That was a good effort.Did you want to have another go with the same settings (Y/N)? NDid you want to start a new Session or Quit (S/Q)? S+————————————————————————+ |||Welcome to the Maths Helper!Use this application to test your knowledge of mathematicsThis program is intended for children from reception to year 7||| 4GE Assignment COMP8702– Semester 1, 2021+————————————————————————+What is your year level?Choose an option from the list below:(where: + = addition, – = subtraction, * = multiplication,/ = division, % = division with remainder)[0] Reception [+][1] Year 1 [+, -][2] Year 2 [+, -]…You are a Reception student and want to do 10 questions. Is this correct (Y/N)? YLet’s begin … (press ‘Q’ at any time to quit)9 + 2 = QThanks for playing.Goodbye.By entering the character ‘H’ the user is able to ask for a hint to be supplied. This hint shoulddisplay the last digit in the answer preceded by a ‘-’ for each extra digit in the answer. Anysubsequent requests for a hint will reveal the preceding digit. A student can continue to requesthelp for the expression until all digits are revealed. If this happens then this question shouldbe graded as incorrect. Example output could be as follows (user input in bold green):84 * 7 = H84 * 7 = –8: H84 * 7 = -88: 588Correct! Well Done! Your current percentage is 100.00%104 * 58 = H104 * 58 = —2: H104 * 58 = –32: H104 * 58 = -032: H104 * 58 = 6032Bad luck that has been marked incorrect because you used all of your hints.Your current percentage is 66.67%The application should respond to the user during a session. If they are finding the tasks toodifficult then the level of complexity should be reduced. The reverse is true if they are findingit too easy – the level of difficulty should be increased. This evaluation should take place aftereach lot of 5 questions. If the user has an overall percentage of more than 75% then increasethe level of difficulty by 1 year level. However, if the user has an overall percentage of less than30% then reduce the level of difficulty by 1 year level. Difficulty cannot be increased above year7 level or reduced below reception level.TasksWhile the steps described below should be completed sequentially you should also pause duringyour development to test recent changes and fix problems as they arise. Don’t leave testinguntil you complete Task 6.Task 1 – Initial PresentationFirst, if you have not done so already, you will need to download and install a version of SVNon your system so that you can connect to the repository and download the files using IntelliJ.5GE Assignment COMP8702– Semester 1, 2021There is information on the FLO page on how to do this for both Windows andMac.HOW TO: Configuring I ntelliJ t o c onnect t o t he repositoryBefore you begin, you will need to download (or check out) the template project from thetopic version control repository that has been setup for this assignment. In CP1, we are usingSubversion, a popular centralised code management system, for this purpose. Subversion iscommonly abbreviated as SVN. If you take further programming topics at Flinders, you willlikely work with version control systems more closely. For now, you will just focus on configuringIntelliJ to connect to the repository so you can download the required files.Open IntelliJ. From the welcome screen, choose Get from Version Control (see Figure 2). Onthe window that appears, select Subversion from the dropdown list. Click the plus button orthe link in the centre of the window (if it is available), see Figure 3, and type in the followingrepository location, replacing FAN with your own FAN (please put your FAN in lower-case!).https://topicsvn.flinders.edu.au/svn-repos/COMP8702/FANFigure 2: Accessing the repository via the New Project screenClick OK. You will likely be prompted to authenticate with the repository server. Enter yourUniversity FAN and password to proceed. The repository location should now be listed (seeFigure 4). Expand the URL, select the MathHelper project, and click Check Out. Choosea location on your machine to save the project from the SVN Checkout Options window thatappears and click OK. This will create a folder in the location you specified containing theproject files. If prompted for a working format, leave 1.8 selected and click OK. Once the checkout process has completed, the project should automatically open in IntelliJ. You can clickAdd to any prompts regarding adding files to Subversion. You are now ready to begin.You can now commit and update from the repository as you see fit (e.g. at the end of eachphase). The markers will also have access to this repository for assessment purposes.You can browse the repository using an internet browser. However, it is expected that youwill use IntelliJ to access the repository (as in Figures 2, 3 and 4) for opening a project,checking out and performing updates and commits. This is accessible both on and off campusand it is expected that you will commit often to the repository.6GE Assignment COMP8702– Semester 1, 2021Figure 3: The result of checking out from therepositoryFigure 4: Checking out the subversionrepositoryOpen the project in IntelliJ and take some time to read through the existing code and thecomments.Once you have loaded the project into IntelliJ you should see several methods defined:• displayWelcome()• displayYearMenu()• displayQuestionMenu()As well as these methods that have content within their body there are also methods thatrequire further definition by you.• letsPlay()• printOutput(String str)• confirmSessionDetails(int year, int questions)Your task is to display the content to the user, capture their input and verify with the user thatthe information they have provided is correct.Looking at the displayWelcome() method you should see that it makes use of many callsto the method printOutput(String str). You will need to define the operation of theprintOutput(String str) method. Looking at the JavaDoc comments above the method youshould be able to determine the functionality of this method. Printing the content to a file will behandled in Task 6 of this assignment, however you will need to provide code to print the stringsto the console screen. Take note of the strings that are being passed to printOutput(Stringstr) to determine whether to use the print() or the println() method.Once you have modified printOutput(String str) to print the string str to the screen youwill need to invoke the methods in the correct sequence. Add the necessary statements to theletsPlay() method to enable this. When you run the program, output from these changesshould look like the following:7GE Assignment COMP8702– Semester 1, 2021+————————————————————————+ |||Welcome to the Maths Helper!Use this application to test your knowledge of mathematicsThis program is intended for children from reception to year 7||| +————————————————————————+What is your year level?Choose an option from the list below:(where: + = addition, – = subtraction, * = multiplication,/ = division, % = division with remainder)[0] Reception [+][1] Year 1 [+, -][2] Year 2 [+, -][3] Year 3 [+, -, *, /][4] Year 4 [+, -, *, /][5] Year 5 [+, -, *, /, negative numbers][6] Year 6 [+, -, *, /, negative numbers][7] Year 7 [+, -, *, /, %, negative numbers]How many questions would you like to attempt?Choose an option from the list below:[1] 10 questions[2] 20 questions[3] 30 questions[4] 40 questions[5] 50 questionsNow you will need to process user input and verify that the user is happy with the menuselections that they have made.A Scanner object scan has already been defined for your needs. Make use of the Scanneroperations to capture the user input. An instance variable yearLevel should be used to storethe user’s response to the year menu and a local variable numQuestions used to store the userinput from the questions menu.Note that the confirmSessionDetails() method is a boolean type method; this means themethod is required to return a true or false value to the calling code.Within the confirmSessionDetails() method you need to present the following informationto the user:You are a yearName student and want to do questions questions. Is this correct(Y/N)?,where the bold values are determined based on user input.At the moment you are capturing two integers from the user and passing them toconfirmSessionDetails(). Complete the following steps to fill in the necessary informationfor the prompt above:• You need to analyse the year value and if it is equal to 0 then yearName should beReception, otherwise yearName should be year year (where bold year represents theinteger passed to the method, i.e. if the user supplied option 5 from the year menu,this would result in year 5).• The value of questions is based on the menu selection, i.e. 1 for 10 questions, 2 for8GE Assignment COMP8702– Semester 1, 202120 questions, 3 for 30 questions . . . You should use this relationship to provide a suitablenumber for questions to the prompt seen above.Finally for the confirmSessionDetails() method you need to capture user input and if theysupply either a ‘Y’ or ‘y’ then they are happy with the input they provided otherwise theprogram will need to repeat the presentation of both menus to the user and capture a fresh setof inputs for yearLevel and numQuestions.To achieve this you will need to return appropriate values (true or false) from the method.Think about the process that you are asking the user to engage in:Do the following:What is your year level?Get user inputHow many questions?Get user inputIs this information correct?Get user inputWhile the information is NOT correct.By following the above process you are locking the user into a loop until they provide a responseindicating that they have supplied the correct information (in this case either ‘Y’ or ‘y’). Thisis achieved through a prompt and test process where you want the program to run throughthe prompt at least once and then verify the user is happy with their input. The loop needsto wrap around the displayYearMenu and displayQuestionMenu method invocations in themain method. The return value you generate from confirmSessionDetails will control therepetition of the loop. If the user has not provided the right details then repeat the loop, ifthey have provided the correct details then end the loop.At this point you should be able to present all the welcome details to the user and have themmake selections from each menu and then confirm the information provided is correct.REPORT TASKYour final task for this part is to document what you have done. Answer the followingquestions:i. What issues (if any) did you encounter with the SVN program?ii. Describe any issues with the code as initially downloaded from the repository.iii. What did you have to fix in order to compile and run the code successfully in IntelliJ?iv. What strategy did you employ to verify that the user provided valid menu item values?9GE Assignment COMP8702– Semester 1, 2021Task 2 – Generating random questionsNow that you have gathered the necessary information from the user it is time to begin theactual session – so start by displaying “Let’s begin!” to the user. Within the letsPlay methodbut after the do loop you completed in the previous step invoke the printOutput method todisplay the string to the console. To generate random questions there are three things that needto be gathered:• the minimum number for a value in the expression• the maximum number for a value in the expression• the range of operators for the expressionAll of these values are based on the year level of the user. Once these elements have beengathered a question is generated and presented to the user. The process for completing thesetasks may look something like:Repeat for the number of questionsAdd one to the countGenerate a question based on the yearGet the minimum valueGet the maximum valueGenerate a random number num1 between the minimum and maximumGenerate a random number num2 between the minimum and maximumGet the operatorPrint num1, operator, num2 to the screenEndThere are many sub tasks that are required to complete the above steps. Overall, we needto repeat these operations for the total number of questions the user has requested – we canuse a counting or for loop to achieve this. Define a for loop that repeats for the number ofquestions and place it after the printOutput(“Let’s begin!”) statement in your letsPlaymethod.We need to work out the user’s percentage of correct answers for a later task in the assignment,to help facilitate this we will use an instance variable called count and increment it each timethe loop repeats, i.e. count++;. Declare the instance variable as type int and set it to 0 andthen within the for loop you have just declared increment the value.So we don’t clutter up the letsPlay method and also to help with readability and re-usabilitywe are going to make use of several methods to complete the above steps.In the space below your existing methods but within the class (ie. before the last }) define anew void type method called generateQuestion(int year):private void generateQuestion(int year) {… }The first thing we need to do within this method is to get the minimum value for the expressionbased on the user’s year level. Declare an int type variable called min that will hold thisminimum value. We will assign the returned value from another method to this variable. To10GE Assignment COMP8702– Semester 1, 2021accomplish this you should complete the variable declaration with an initialization statement,i.e.:int min = getMin(year);When you type this in you should see an indicator (small light bulb with red warning sign)appear in the line number margin within IntelliJ. Clicking once on the indicator brings up asmall popup box with a message within that reads:Create method “getMin(int)” in MathHelperClicking on this message will get IntelliJ to create a method declaration for this method.Looking at the specification above you can see that all students from reception to year 4 havea minimum value of 0, while students in year 5 and 6 have a minimum value of -999, and year7 users have a minimum value of -9999. With this knowledge you could create a collection of ifstatements or use a switch statement to get the right value for the year level. The pseudo codebelow describes the type of decisions that could be made:If year equal 0Set min to 0If year equals 1Set min to 0If year equals 2Set min to 0If year equals 3Set min to 0If year equals 4Set min to 0If year equals 5Set min to -999If year equals 6Set min to -999If year equals 7Set min to -9999However, we can simplify this, consider:Set min to 0If year equals 5 or 6Set min to -999If year equals 7Set min to -9999With the above pseudo code we are setting the starting value to 0 and if none of the conditionsare met then this min value is not changed. This essentially allows us to set min to 0 (nonegative numbers until year 5) for all year levels from reception to year 4 with one line of code.Using this shorter example of pseudo code implement this as working Java code within yourgetMin() method.Based on the above discussion complete similar steps for the max value. Declare a local variablecalled max and assign it a value returned from a getMax() method.Once you have identified the maximum and minimum ranges to the numbers within the expressionyou can then generate the appropriate random numbers.11GE Assignment COMP8702– Semester 1, 2021Declare local variables called num1 and num2 to hold the random values generated.The next step in our plan is to get the operator that is to be used for the expression. As withthe min and max values the range of operators that the expression can have is based on the yearlevel of the user. Reception students only have one operator (+) for their expressions, year 1and 2 students can have possibly 2 operators (+, -), while year 3, 4, 5, and 6 students can have4 operators (+, -, *, /) and finally year 7 students can have 5 operators (+, -, *, /, %). As theoperators should be generated randomly we need to create a process that identifies first howmany possible operators we have access to and then generate a random value within that rangethat maps to the operators. Using the same principles as getMin and getMax we can base ourdecision on the year level, i.e.:Set operatorBounds to 1If year equals 1 or 2Set operatorBounds to 2If year equals 3 or 4 or 5 or 6Set operatorBounds to 4If year equals 7Set operatorBounds to 5Once we have the bounds we can then generate a random number within these bounds.Generate a random number between 1 and the operatorBounds and return this value to thecalling method and assign it to an int variable oper.The final step is to convert the int oper into a character that represents the type of operationthat we want to perform in our expression. In your generateQuestion method create a switchbased on the oper value that will assign a character to the local char variable op, i.e:oper == 1 → op = ‘+’oper == 2 → op = ‘–’oper == 3 → op = ‘*’oper == 4 → op = ‘/’oper == 5 → op = ‘%’As with the count variable discussed earlier we are laying the ground work for future tasksand so we are placing the logic within the generateQuestion method rather than the getOpermethod to help with the calculation of results from the expression – covered in Task 3.Now you should have two int values assigned to num1 and num2 and a char value assigned toop. The last step for this task is to combine these values into a string and print the stringto the console using printOutput. This statement should be placed at the bottom of yourgenerateQuestion method.Finally, add the method invocation generateQuestion(yearLevel) to the loop you defined atthe start of this task. When you run your code you should see output similar to the following:user input bold green.+————————————————————————+ |||Welcome to the Maths Helper!Use this application to test your knowledge of mathematicsThis program is intended for children from reception to year 7||| +————————————————————————+What is your year level?12GE Assignment COMP8702– Semester 1, 2021Choose an option from the list below:(where: + = addition, – = subtraction, * = multiplication,/ = division, % = division with remainder)[0] Reception [+][1] Year 1 [+, -][2] Year 2 [+, -][3] Year 3 [+, -, *, /][4] Year 4 [+, -, *, /][5] Year 5 [+, -, *, /, negative numbers][6] Year 6 [+, -, *, /, negative numbers][7] Year 7 [+, -, *, /, %, negative numbers]5How many questions would you like to attempt?Choose an option from the list below:[1] 10 questions[2] 20 questions[3] 30 questions[4] 40 questions[5] 50 questions2You are a year 5 student and want to do 20 questions. Is this correct (Y/N)? yLet’s begin!107 / -10 = 635 + -884 = -737 + -560 = -90 * 940 = 290 / -151 = 113 / 594 = -464* 73 = 826 – -924 = 271 / 478 = -471 * -666 = -885 + -542 = -107 * -666 = 922 –769 = -96 + 996 = -728 / -704 = -553 – 372 = 472 * 917 = -451 – 982 = -920 + -500= 77 / -389 =You will notice that all the questions flow on to one and other on the same line. This will becorrected during the next task where you will start to process user answers.REPORT TASKAnswer the following questions:i. The company has changed the specifications and would now like year level 4 to includenegative numbers and year level 6 questions to include modulo division. How would youneed to change the code to achieve this?ii. The company has notified you that questions should now be output in a slightly differentformat that includes a prefix identifying the question number in the format Qn where nis the question number. For example, an addition question that is the first question inthe set should appear as:Q1. 6 + 3 =What would you need to change in the code to accomplish this?13GE Assignment COMP8702– Semester 1, 2021Task 3 – Evaluating the answersNow that the random questions are being generated we need to calculate the result of theexpression and confirm that the user has provided the correct a nswer. We will b e using stringsto do all our comparisons between the calculated result and the user supplied answer, so yourfirst task is to declare a local string variable result within the generateQuestion method andassign it an empty string. Within the switch statement you defined i n t he l ast t ask ( used todetermine an operator) you should implement the appropriate calculation and assign the resultto the string variable.If the operator is +Set result to (num1 + num2)If the operator is –Set result to (num1 – num2)If the operator is *Set result to (num1 * num2). . . etc.Remember that the output from the division with remainder should be XrY, where X is theresult of the division operation and Y is the result from the modulus operation. This is partlythe reason for defining result as a string.Test your calculations by concatenating result to the end of your printOutput call at the bottomof the generateQuestion method. The output you get should be testable with a calculator.When you run your code you should see something like the following (I have concatenated anadditional space after result to break the expressions up, the following has been created for ayear 7 wanting 40 questions):Let’s begin!5591 – -5502 = 11093 9240 * 4355 = 40240200 7409 / -4570 = -1 -1157 * 1077 = –1246089 5084 % 259 = 19r163 -3660 – -3298 = -362 -4008 / -2987 = 1 567 / -6323 =0 2430 / -40 = -60 -129 / -1327 = 0 -445 * -4832 = 2150240 -6845 / -1975 = 3 813* 4588 = 3730044 7825 * -1115 = -8724875 -2101 % 2410 = 0r-2101 8663 + -9640 = –977 -9374 % -6708 = 1r-2666 -6683 % -9726 = 0r-6683 6171 % -542 = -11r209 -7067* 3081 = -21773427 1022 / -762 = -1 5030 / 3358 = 1 9279 + 9013 = 18292 -1406 *8914 = -12533084 -693 % 2860 = 0r-693 5130 / 5450 = 0 9873 * 6406 = 63246438 4432/ -955 = -4 -4051 – 4732 = -8783 -1717 – -1628 = -89 2486 – 7542 = -5056 1905 *-9607 = -18301335 8019 – 1058 = 6961 -8438 * -7187 = 60643906 -5321 + -3679 = –9000 -8402 / 6044 = -1 464 / 2248 = 0 -2263 / -5231 = 0 6201 / -7971 = 0 1136 +3690 = 4826Once you are satisfied that the result is being calculated correctly remove the reference to resultfrom your printOutput method call.Your task now is to evaluate whether the user has provided the correct answer. We will defineand call a method to complete this action. At the bottom of your generateQuestion methodwrite the following statement:evaluateAnswer(result);Use the process described previously to get IntelliJ to declare a new method with the appropriatesignature for the evaluateAnswer(result) method. Within this method we need to capturethe user input and compare it to the result the program generated. The following pseudo codedescribes this process.14GE Assignment COMP8702– Semester 1, 2021Set userIn to the user inputIf userIn is the same as resultIncrement correctPrint “Correct! Well Done!Your current percentage is calculatedPercentage”OtherwisePrint “Bad luck that was incorrect. The correct answer was result.Your current percentage is calculatedPercentage”Something that you should note – we are comparing strings for equality – use the appropriatestructures to assess this equality.You will notice that there are two new things that have been described above: correctand calculatedPercentage. correct should be an instance variable that gets initialised tozero and then increments every time the student enters the correct answer. We can thenuse this correct value combined with our count value defined previously to calculate thecalculatedPercentage, i.e. correct/count (remember this will be integer division but wewant a double value).calculatedPercentage should be formatted to 2 decimal places. At the moment we are usingprintOutput to send our strings to the output window, however, printOutput only accepts astring as an argument. You will need to use an appropriate method to format the output as astring percentage.This means we cannot send this information to our current printOutput method (it onlyaccepts a single string as an argument). To deal with this we will overload the printOutputmethod.Declare a second void method called printOutput but declare formal parameters of type stringand double. Within this method make use of the method you determined above to display thestring and double appropriately formatted.This will result in the output looking something like:Correct! Well Done! Your current percentage is 100%With the cursor waiting at the end of the line, which means the following expression will bedisplayed on the same line, i.e.:Correct! Well Done! Your current percentage is 100%50 + 72 =Obviously this is not something that we want to happen; we want a percentage symbol after100.00 and to place the cursor on a new line. To get the new lines we use the same use escapesequences to introduce a new line as we have in the displayWelcome method.At this point you should be able to run your program and have it present an expression to theuser and they should be able to provide a response. This response should then be evaluatedagainst the actual answer and then an appropriate message displayed to the user.The last step for this task is to display a final message to the user when they have finishedthe sequence of questions. This message should be based on their percentage achieved duringthe session. When the loop generating questions has concluded you will need to calculate thepercentage and present this:Your final score was calculatedPercentage%Use the following pseudo code to define the next part of the message presented to the user:If calculatedPercentage is less than 4015GE Assignment COMP8702– Semester 1, 2021Print “Bad luck. Try practicing with some of the lower year levels to build your confidence and skills”If calculatedPercentage is between 40 and 49Print “That was a good effort but you may need to work on some of the expressions”If calculatedPercentage is between 50 and 59Print “Congratulations you passed. Keep practicing at this year level to improve your score”If calculatedPercentage is between 60 and 74Print “Well done. That was a good effort.”If calculatedPercentage is between 75 and 84Print “Good job. You should try the next year level in your next test”If calculatedPercentage is more than 84Print “Excellent work! You really know your stuff. Try the harder levels next time”REPORT TASKAnswer the following questions:i. Describe your implementation of the evaluateAnswer method. Explain how you read inthe user’s response to each question, check whether their answer is correct, and outputthe appropriate feedback.ii. The company has asked you to modify the program to include a count of the run ofcorrect answers and output encouraging messages for the length of the run.How would you need to change the code to achieve this, and what foreseeable problemsmay you encounter?16GE Assignment COMP8702– Semester 1, 2021Task 4 – Adaptive DifficultyFor this task you should modify the program to respond to users who are either doing reallywell or really poorly.After each block of five questions if the calculated percentage is greater than 75% the programshould increase the difficulty by raising the yearLevel by one and displaying the message:“You are doing well! Let’s increase the difficulty a little.”However, if the calculated percentage is less than 30% then you should lower the yearLevel byone and display the message:“It seems your are having some difficulty. Let’s reduce the difficulty a little.”You need to think about where the best place is to implement this test. Remember you havean instance variable that tells you how many questions have been attempted during the session.You should also be aware that the yearLevel cannot go below 0 or above 7.REPORT TASKAnswer the following questions:i. Describe why you chose the place to implement this test and what, if any, methods orvariables you were required to implement/create.ii. Would it be easy to change the frequency of the check if required, i.e. after each blockof 7 questions?Describe how this could be achieved.Task 5 – Providing Hints and QuittingTRICKYWith this task you will implement a system that allows the user to supply characters ratherthan digits when answering each expression. The user will be able to type ‘q’ or ‘Q’ and quitthe application completely. They can also type ‘h’ or ‘H’ to receive a hint about the currentexpression.These user inputs will be caught at the same point where the user provides answers to eachexpression. When you evaluate the answer you should define a statement that tests whetherthe user has entered ‘q’ or ‘Q’, if they have then use the statement:System.exit(0);to close the program.To get the hint functionality working you will need to lock the user into a loop that presentsa restructured expression every time they enter ‘h’ or ‘H’. For example, given the followingexpression (user input in bold green):-6804 + 2820 = hIf the user supplied ‘h’ for their answer then the expression should be restructured and display:-6804 + 2820 = ––4:and wait for the user to either supply an answer or request another hint or quit, for example:17GE Assignment COMP8702– Semester 1, 2021-6804 + 2820 = —-4: h-6804 + 2820 = —84: h-6804 + 2820 = –984: -3984Correct! Well Done! Your current percentage is 100%If the user requests too many hints (i.e. a hint for every digit in the answer) then the guessshould be registered as incorrect and the normal process should follow.To get the presentation of the hint correct you will need to keep track of how many hints havebeen requested for the current expression. Use this value to display a string of “-” concatenatedtogether. This value you have used to hold the total number of hints can also be used to createa substring that you should concatenate to the end of your string of “-”. Then display therestructured expression to the user and retrieve their input. If the input is ‘h’ or ‘H’ thenrepeat the process – use the following pseudo code to help:Set hint to an empty stringRepeat while user asks for a hintRepeat for (length of result – number of hints)Set hint to hint + “-”Set hint to hint + a substring of result starting at the character at position(length of result – number of hints)Print num1 + “ “ + op + “ “ + num2 + “ = ” + hint + “: ”Get user inputIf the user types in a digit then the normal processing should occur and the program shouldtest the correctness of the user’s answer.REPORT TASKAnswer the following question:i. Describe any difficulties you had in developing the solution to this task.Task 6 – Logging and multiple sessionsFor the last task you will need to implement a mechanism to allow for a log of all activity duringthe session to be written out to a text file for later review by the teacher. You will need to use aPrintWriter object to output to a text file. Each session should have its own unique text file –the easiest way to complete this is to use the system time (in milliseconds) as the file name. Toget this value you can use the statement System.currentTimeMillis(). Concatenate a stringcontaining “.txt” to the time generated and assign this to a string called file. Use file as theargument for the creation of a new PrintWriter. Now whenever you need to print somethingto the screen you should also print the same content to the text file – this should be done withinyour printOutput methods.The challenge however is to capture user input and print this to the text file. Consider whenyou capture this input and what you do with it.When working with a file you need to be aware that your program may have difficultiesfinding the file and you will also need to close the file when exiting your program (i.e. beforeSystem.exit(0)).Once you have this process working you should then set up your project to allow for multiple18GE Assignment COMP8702– Semester 1, 2021sessions. These sessions should allow the user to repeat with the same settings (year level andnumber of questions) or begin a new session with new settings. When you present the user withtheir final score display the following message to the user:“Did you want to have another go with the same settings (Y/N)?”If the user supplies ‘y’ or ‘Y’ then print “Let’s begin!” and start generating new randomquestions. If however the user supplies ‘n’ or ‘N’ then present them with the following message:“Did you want to start a new session or quit (S/Q)?”If they supply ‘s’ or ‘S’, then display the welcome message and the menus so they can define newparameters for the next session. If they supply ‘q’ or ‘Q’ then quit the application. Your finalrequirement is to ensure the user enters the correct information into the menus. If they entera value that is not recognized by the menu (i.e. a letter, symbol or digit outside the bounds ofthe menu options) then present the menu to them again until they supply a legal value.REPORT TASKAnswer the following questions:i. Describe how you captured user input and printed this to the text file.ii. The company has asked you to write a Graphical User Interface for the program youhave written. Could it be used as is, or would you need to rewrite parts of the code toaccomplish this? Discuss and explain.19

QUALITY: 100% ORIGINAL PAPER – NO PLAGIARISM – CUSTOM PAPER

Leave a Reply

Your email address will not be published. Required fields are marked *