1 attachmentsSlide 1 of 1

- attachment_1attachment_1

### UNFORMATTED ATTACHMENT PREVIEW

Lab Homework Summer 2021 Due: Sunday, 15 Aug 2021, 11:59pm Name: CSE2315-001 Tiernan UTA ID: Due: Sunday, 15 Aug 2021, 11:59pm. ** NO LATE WORK ACCEPTED. ** You may turn in homework with less than 100 points on it for credit. Read all the instructions at the beginning and the end of this document. Instructions for Lab Homework 1. Lab homework will always require you to submit code files and output. The output format will be specified in the assignment and may include screenshots, output files created by the program, or other documentation. If input files are created to run the homework, those input files must be submitted also. 2. You may write your program in C, C++, or Java. Java programs will be tested in NetBeans. C and C++ programs will be tested under gcc and/or Visual Studio. 3. You must include the following information in the header comments of every code file you submit. This includes files with separate functions or classes as well as the main program file. CSE 2315 Summer 2021 Tiernan Name: UTA ID: Question # and part, if appropriate: Programming language used for homework: IDE and compiler used for homework: Any additional info that would be needed for someone to run the program and grade it: 4. Lab HW code files must be named with your lastname, your first initial, then “Q#File#”. So if your name is Happy Camper, the Lab Homework Question you are answering is 3.a, and you are submitting 4 files total for this question (ex. a main program .java file, two screenshot .jpg files, and an input .txt file) then your file names would be CamperHQ3aFile1.java , CamperHQ3aFile2.jpg , CamperHQ3aFile3.jpg , and CamperHQ3aFile4.txt . Be sure that your input file name in the program matches the input file name for the file you are turning in, i.e. if you are turning in CamperHQ3aFile4.txt as the input file then your program should not be reading in “input.txt”, it should be reading in “CamperHQ3aFile4.txt ” 5. Almost every question asks you to submit labeled screenshots of your output. Make one file named LastnameILabAnswers, ex. CamperHLabAnswers.docx. This should be a .txt, .docx, or .pdf file. Put ALL the screenshots for all the questions into this one file. This file will be saved with your other files and submitted for the lab homework. 6. Lab Homework must be submitted on Canvas. There is info at the bottom about creating a folder for your assignment files to be turned in. 7. If you submit a partial working program, for example, it does some but not all of the required tasks, you may receive partial credit as long as the program does not crash when it is run. Likewise, if your program runs but gets incorrect answers, you may receive partial credit if your code can be reviewed and your error determined. 8. If you have questions, e-mail Dr. T or ask the question on the Canvas discussion board. All general questions (e-mailed and otherwise) will be answered on the discussion board. Lab Homework Summer 2021 Due: Sunday, 15 Aug 2021, 11:59pm CSE2315-001 Tiernan REMINDER: Do not submit an entire project folder from your IDE for any question. Submit ONLY the code file(s) that are specified. If you submit the entire project folder rather than the code file(s), you will lose ½ of the points for this part of the assignment on top of any other deductions. 9. Submit the required problems and then complete additional selected problems in this lab homework for credit up to a maximum of 110 points. The required problems are • • Problem 1 worth 29 points Problem 3, 4 OR 5 worth 13 points (3 and 5) or 18 points (4). Only one of these three problems should be submitted. The first one listed in the answers document will be graded and any others ignored. At this point you will have either 42 or 47 points completed. Complete additional problems to make up to or over 100 total points. Note that you must complete all parts of a problem in order to get credit. You may reach over 100 points simply through your choices of problems which add up to more than 100 points. There is an extra credit 5 point question at the end of Problem 1 and an XC problem at the end worth 8 points. Note that these two problems will not count toward calculating the first 100 points. This means if you do 97 points of regular problems and 13 points of extra credit, your maximum score is 107 because you did not do 100 points of regular problems. You may earn up to a maximum of 110 points worth of credit on this lab assignment regardless of how much work you turn in including both required, selected and extra credit problems (so don’t do things that don’t count unless you want to) Problem values Problem 1: 29 points Problem 1e Extra Credit: 5 points Problem 2: 24 points Problem 3: 13 points Problem 4: 18 points Problem 5: 13 points Problem 6: 32 points Problem 7: 25 points Problem 8: 33 points Problem 9: 24 points Problem 10: 28 points Problem XC1 Extra Credit: 8 points Lab Homework Summer 2021 Due: Sunday, 15 Aug 2021, 11:59pm CSE2315-001 Tiernan Submit the required problems (1 and 2) and then additional selected problems in this lab homework for credit up to a max of 110 points Complete problems 1 REQUIRED: 1) Practice recurrence relations and combinations Parts a – d must be completed to receive credit. {29 pts total, parts a-d} 1) Write a program to implement the recurrences as described below. Each type of recurrence will calculate the same value in a different way. For this question you must turn in the program you write with all methods/functions included and you must include the output from test runs with the following values: Test run 1: a = 1, b = 5, n = 6 Test run 2: a = 2, b = 3, n = 4 Test run 3: a = 7, b = -1, n = 3 You may include other test runs if desired. Your test run output should be screenshots of the output produced by your program into your LastnameILabAnswers file. Make sure the output includes enough info so that the grader can determine what the output represents. {output screenshots and information 4 points} 1.a) Write a main main method/program/routine that will allow the user to enter values for two integers a and b, and non-negative integer n and then call each of the three functions defined below (in parts 1.b, c, and d) with those input values. The main method/program should indicate to the user what range of values they may input for a, b, and n and should check the input values. Once the user has entered valid inputs, the program should call the binomial theorem method (or function) (1.b), then save and print the result. Then the program should call the exponentiation method (1.c) and save and print that result. Finally the program should call the repeated multiplication method (1.d) and save and print the result. The main program should then compare each of the three results to determine if they are the same and should print messages to the user indicating if no results are the same, two results are the same, or all three results are the same. After printing the results comparisons, the main program should ask the user if they would like to enter another set of input values and if so, run again letting the user give new inputs. The format of the output for each called method/function should look like: (a+b)^n = B as calculated by the M method where a, b, and n are the inputs,^ represents exponentiation, B is the value that is calculated and M is the method name. So if a = 1, b = 2, n = 3, and the output is calculated by the exponentiation method then the output for that would look like: (1+2)^3 = 27 as calculated by the exponentiation method {7 pts for main routine} Lab Homework Summer 2021 Due: Sunday, 15 Aug 2021, 11:59pm CSE2315-001 Tiernan Rubric: Correctly accept inputs for a, b, and n from user and verify the input value validity {1 pt} Call the binomial theorem function (part 1b) with a, b, and n as inputs and numeric return value and then print message as described above {1 pt} Call the exponentiation function(part 1c) with inputs and return value then print message {1} Call the repeated multiplication (part 1d) with inputs and return value then print message {1} Correctly compare results from three function calls and give appropriate output {2 pts} Allow user to run again and input new values {1 pt} 1.b) Implement the binomial theorem (see section 4.5 for full description of binomial theorem) as a method (or a function if using C/C++) to compute of (a + b)n with integer input values of a, b, and non-negative integer input n. Use the specific formalism of the of using the combinations C(n,k) in the summation with the terms an-kbk. The method/function should return the value of the computation to the calling routine. The calling routine should print an output message in the form shown above and stating that the binomial theorem was used to calculate the result. You must implement the binomial theorem in this method to get any points. {8 pts} 𝑛 𝑛−𝑘 𝑘 n Binomial theorem: (a + b) = ∑𝑘=0 𝐶(𝑛, 𝑘)𝑎 𝑏 or in alternate notation (a + b)^n = summation of k from 0 to n of [C(n,k)*a^(n-k)*b^k] Rubric: Correctly implement method with appropriate header, parameters, and return values {2 pts} Correctly implement the binomial theorem in the method/function {6 pts} 1.c) Create a second method/function, the “exponentiation” method, to compute a + b and raise this value to the nth power. This method/function should take the integer values of a, b, and nonnegative integer input n as inputs. The method/function should return the value of the computation to the calling routine. The calling routine should print an output message in the form shown above and stating that the value of (a + b) was raised to the nth power to calculate the result. Use a built-in operator or method/function (such as the Java Math.pow() method, the ^ operator in Haskell, or the ** operator in Python) for calculating the power, i.e. doing the exponentiation. You must implement the “exponentiation method” in this method as described to get any points. {6 pts} Rubric: Correctly implement method with appropriate header, parameters, and return values {1 pts} Correctly implement the use of exponentiation by an operator or a method call in this method/function {5 pts} 1.d) Create a third method/function, the “repeated multiplication” method, to compute a + b and then multiply this value by itself n times. This method/function should take integer values of a, b, and non-negative integer input n as inputs. The method/function should return the value of the computation to the calling routine. The calling routine should print an output message as shown above stating that the value of (a + b) was multiplied by itself n times to calculate the result. You must implement the “repeated multiplication method” in this method as described to get any points. {8 pts} Lab Homework Summer 2021 Due: Sunday, 15 Aug 2021, 11:59pm CSE2315-001 Tiernan Rubric: Correctly implement method with appropriate header, parameters, and return values {2 pts} Correctly implement repeated multiplication to find the value of the power in the function {6 pts} 1.e) OPTIONAL EXTRA CREDIT: Create a program that does all the same things as the previous programs except that a and b can be floating point numbers rather than integers and n can be any integer. NOTE: if you are using floating point numbers in your program, you may need to test for equality within some delta of each other, i.e. that the results are the same within 0.0001, for example, of each other. The delta value should be small relative to smallest of a, b, or ab.{XC 5 pts} 2) Practice permutation and combination All parts must be done to receive any credit {24 pts total for parts a-e} 2.a) Write a main method/program that will have a loop that allows the user to enter two values n and r during each loop and then call two functions/methods inside the loop as described below. The program/main method should have loop that will allow the program to be run multiple times before stopping with different user inputs for each iteration. This will be controlled with a question to the user at the bottom of the loop asking if they wish to run the program again. Inside the loop, the program/main method should give the user a message asking for two integers and should tell the user that the value of n must be greater than or equal to r and the value of r must be greater than or equal to 0. The main method/program should get input from the user for two integers n and r. After the user enters the two values, the program should validate the input to make sure that both inputs are greater than 0 and that n ≥ r. If the user input is valid, the program should use n and r to call the first function P (question H.b) passing in n and r as inputs. P will return an integer output to the main routine and this should be saved and printed in a message on its own line like: P(n,r) = result with the actual numeric values filled in. For example, if n = 2 and r = 1, then the result of P will be 2 so the output will look like: P(2,1) = 2 . Following the call to P, the main method/program should call the second function C (question H.c) passing in n and r as inputs. C will return an integer output to the main routine and this should be saved and printed in a message on its own line like: C(n,r) = result with the actual numeric values filled in. For example, if n = 2 and r = 1, then the result of C will be 2 so the output will look like: C(2,1) = 2 . Lab Homework Summer 2021 Due: Sunday, 15 Aug 2021, 11:59pm CSE2315-001 Tiernan Once the values of P(n,r) and C(n,r) have been calculated, then print out a message indicating the difference between P(n,r) and C(n,r), that is, P(n,r) – C(n,r) with the actual numeric values filled in on its own line. P(n,r) – C(n,r) = difference After the difference has been printed, the program should ask the user if they wish to run the program again. If the user input is invalid, the program should print a message for the user and then ask the user if they wish to run the program again. After asking the user if they wish to run the program again, the main method/program can have the user respond in any number of ways their answer. The program can ask for a numeric value, ex. “Enter 1 to run again and 0 to stop”, or letter value, ex. “Type Y to run again or N to stop”, or a word etc. The program must tell the user how to respond to the question and then read in the user’s response. If the user’s response to the question is invalid, the program should stop and end the loop appropriately. Use a simple text interface for this interaction – no pop-up windows or other graphics should be used. DO NOT USE a BREAK, CONTINUE, EXIT, or GOTO statement in this program. As long as the user responds positively, the program should loop to the top and ask for two new input values. When the user responds negatively, the program should stop (ending the loop gracefully) and print out a thank you message. {7 pts} Rubric: Correct declaration of n and r and required variables to save results of P and C {1 pt} Main has a loop to get user input for n and r, call functions P and C, print outputs and difference, and run again if desired. Bottom of loop correctly allows user to run loop again if desired. {2 pts} Correctly asks user to input n and r, reads input, validates input as specified, and handles incorrect input {1 pt} Correctly calls functions P and C, saves output values, and print outputs {1 pt} Correctly calculates and prints difference in outputs of P and C {1 pt} Main correctly implements all requirements as stated {1 pts} 2.b) The P function will calculate the permutation of P(n,r) and return an integer value to the calling routine. P should accept two integer inputs n and r. The P function should calculate the permutation by calling a factorial function fact (question 2.d) each time that a factorial value is needed in the permutation calculation. Once the permutation has been calculated, the value should be returned as the output return value from function P to the calling routine. {5 pts} Rubric: Function/method P correctly accepts inputs n and r {1 pt} P correctly implements formula for permutation {1 pt} P correctly calls factorial function in permutation formula {1 pt} P correctly returns permutation value {1 pt} P correctly implements all requirements as stated {1 pt} Lab Homework Summer 2021 Due: Sunday, 15 Aug 2021, 11:59pm CSE2315-001 Tiernan 2.c) The C function will calculate the combination of C(n,r) and return an integer value to the calling routine. C should accept two integer inputs n and r. The C function should calculate the combination by calling a factorial function fact (question 2.d) each time that a factorial value is needed in the combination calculation. Once the combination has been calculated, the value should be returned as the output return value from function C to the calling routine. {4 pts} Rubric: Function/method C correctly accepts inputs n and r and returns combination value {1 pt} C correctly implements formula for combination {1 pt} C correctly calls factorial function in combination formula {1 pt} C correctly implements all requirements as stated {1 pt} 2.d) The fact function will accept one input integer and will return the factorial value of that integer. The fact function should be recursive to calculate the factorial value. {4 pts} Rubric: Function/method C correctly accepts integer input and returns factorial value{1 pt} C correctly implements recursive formula for factorial {2 pt} C correctly implements all requirements as stated {1 pt} 2.e) For this question you must turn in the program you write with all methods/functions included and you must include the output from test runs with the following values: Test run 1 must include all of the following test values n = 5, r = 2 n = 10, r = 3 n = 10, r = 7 Test run 2 must include all of the following test values n = 0, r = 1 n = 3, r = 0 n = 8, r = -6 You may include other test runs if desired. Your test run output should be labeled screenshots of the output produced by your program and stored in your LastnameILabAnswers answer file of type txt, docx, or pdf. Make sure the output includes enough info so that the grader can determine what the output represents. {code file, output screenshots, and contents 4 points} Complete one of problems 3, 4, or 5. Only one can be submitted for credit REQUIRED Choose only one of 3, 4, or 5 3. Practice number theory and sequences {13 points total for parts a and b} Both parts must be done to receive any credit An arithmetic progression (arithmetic sequence) is a sequence of terms where there is an initial term a and each succeeding term is obtained by adding a common difference d to the previous term. The formula for the sum of the first n (n ≥ 1) terms of an arithmetic sequence is: a + (a + d) + (a + 2d) +…+ [a + (n − 1)d] = (n/2)[2a + (n − 1)d] Lab Homework Summer 2021 Due: Sunday, 15 Aug 2021, 11:59pm CSE2315-001 Tiernan 3.a) Write a program/main method that takes in three inputs from the user and the calculates the sum of the first n terms of the arithmetic sequence defined by those inputs and the formula for an arithmetic sequence. Your program will calculate this sum in two different ways and compare the results. Your main method/program should tell the user that it will calculate a sum for an arithmetic sequence: a + (a + d) + (a + 2d) +…+ [a + (n − 1)d] Your program should ask the user for three integers: n the number of terms in the arithmetic progression, the initial term a, and the common difference d. Using those three values your program will do two different calculations. Calculation 1: The first calculation will iterate using the formula for the sequence to find the sum. For example, if the user inputs n =5, a = 3, and d = 2, then your program should calculate the following terms in a loop: a, HINT: Can you rewr…

Do you similar assignment and would want someone to complete it for you? Click on the **ORDER NOW** option to get instant services at **essayloop.com**

Do you have a similar assignment and would want someone to complete it for you? Click on the ORDER NOW option to get instant services at essayloop.com. We assure you of a well written and plagiarism free papers delivered within your specified deadline.