2023 Problem 1 Start up DrRacket if necessary setting the language to How To Design Programs Beginning Student level | Assignment Collections

Computer Science 2023 computer sience homework

2023 Problem 1 Start up DrRacket if necessary setting the language to How To Design Programs Beginning Student level | Assignment Collections

Problem 1 Start up DrRacket, (if necessary) setting the language to How To Design Programs – Beginning Student level, and adding the HTDP/2e versions of the image and universe teachpacks by putting these lines at the beginning of your Definitions window: (require 2htdp/image) (require 2htdp/universe) Put a blank line, and then type in: • a comment-line containing your name, • followed by a comment-line containing CS 111 – HW 3, • followed by a comment-line giving the date you last modified this homework, • followed by a comment-line with no other text in it — for example: ; type in YOUR name ; CS 111 – HW 3 ; last modified: 2016-02-08 ; Below this, after a blank line, now type the comment lines: ; ;

Problem 1   ; Note: you are NOT writing a function in this problem — you are just writing two compound expressions. Sometimes, when a function returns a number with a fractional part, especially a number such as the result of (/ 1 3), it becomes difficult to give an expected value in a check-expect that is “exact enough” for a passing test. Yet, if the expected value is “close enough” to the actual value, we might like to be able to decide that that is good enough for our purposes. That is why, along with several additional check- functions,  BSL Racket also includes check-within, which expects three arguments: • the expression being tested, which in check-within’s case should be of type number • an approximate expected value for that expression • a number that is the largest that the difference between the expression and the expected value can be and still consider this to be a passing test. (In math, this maximum difference is also called a delta.) As a quick example, what if you simply wanted to test whether BSL Racket’s predefined pi was within .001 of 3.14159? This check-within expression can do this, and show that it is:
CS 111 – Homework 3 p. 4 ; passing test (check-within pi              3.14159              .001) But if you want to know if its predefined pi is within .000001 of 3.14159, this check-within expression can do this, and show that it is not: ; failing test (check-within pi              3.14159              .000001) Just to practice writing a few expressions using check-within: • write a check-within expression that will result in a passing test for testing what the expression (/ 1 3) …should be roughly equal to; • write a check-within expression that will result in a passing test for testing what the expression (* pi 10 10) …should be roughly equal to. Problem 2 Next, in your definitions window, after a blank line, type the comment lines: ; ;

 

Problem 2 ; True story: my spouse likes to set every item that displays a temperature to display that temperature in Celsius. That prompts an idea: I decide I’d like a function that expects a temperature given in Celsius, and returns the equivalent Fahrenheit temperature. Write such a function cels->fahr, using the following design recipe steps: (It is reasonable to search the web or an appropriate reference for the conversion formula for this — consider it problem research.) 2 part a Write an appropriate signature comment for this function. 2 part b Write an appropriate purpose statement comment for this function. 2 part c Write an appropriate function header for this function (putting … ) for its body for now).
CS 111 – Homework 3 p. 5 2 part d Write at least 2 specific tests/check-expect or check-within expressions for this function. 2 part e Only NOW should you replace the … in the function’s body with an appropriate expression to complete this function. Run and test your function until you are satisfied that it passes its tests and works correctly. Finally, include at least 2 example calls of your function (such that you will see their results) after your function definition.

 

Problem 3 Next, in your definitions window, after a blank line, type the comment lines: ; ; Problem 3; I decide I’d like a function name-badge that expects a name, and returns an image of a “name badge” for that name: a shape (of your choice of shape and color) with the given name in its middle. Somehow make the width of your “badge” be based on the name’s length. (hint: remember that string-length expects a string and returns how many characters is in that string.) 3 part a Write an appropriate signature comment for this function. 3 part b Write an appropriate purpose statement comment for this function. 3 part c Write an appropriate function header for this function (putting … ) for its body for now). 3 part d Write at least 2 specific tests/check-expect or check-within expressions for this function. 3 part e Only NOW should you replace the … in the function’s body with an appropriate expression to complete this function. Run and test your function until you are satisfied that it passes its tests and works correctly. Finally, include at least 2 example calls of your function (such that you will see their results) after your function definition.

 

Problem 4 We’ve mentioned the make-color function, which expects three arguments, each an integer number in [0, 255], representing its red, green, and blue values, respectively, and returns a color made up of those red,
CS 111 – Homework 3 p. 6
green, and blue values. Optionally, it can take a 4th argument, another integer in [0, 255], giving the transparency of that color (0 is completely transparent, 255 has no transparency). But – to play with this is a little inconvenient, because to “see” what the returned color looks like, you have to use the resulting color in some image function. Design a function color-swatch that expects desired red, green, and blue values, and returns a solid rectangle image whose color has those red, green, and blue values. (You can pick a reasonable constant size for this rectangle.) OPTIONAL: if you’d like, you can also design this to expect a transparency value, also. 4 part a Write an appropriate signature comment for this function. 4 part b Write an appropriate purpose statement comment for this function. 4 part c Write an appropriate function header for this function (putting … ) for its body for now). 4 part d Write at least 2 specific tests/check-expect or check-within expressions for this function. 4 part e Only NOW should you replace the … in the function’s body with an appropriate expression to complete this function. Run and test your function until you are satisfied that it passes its tests and works correctly. Finally, include at least 2 example calls of your function (such that you will see their results) after your function definition. Problem 5 Next, in your definitions window, type the comment lines: ; ;

 

Problem 5 ; 5 part a Remember that place-image expects a scene expression for its 4th argument. It can be convenient to use a named constant for this scene, especially if you will be using it in a number of place-image expressions and if it might itself include several unchanging elements. You are going to be creating some scenes in later parts of this problem, so for this part, define the following named constants: • define a named constant WIDTH, a scene width of your choice (except it should not be bigger than 1300 pixels).
CS 111 – Homework 3 p. 7 • define a named constant HEIGHT, a scene height of your choice (except it should not be bigger than 400 pixels). • define a named constant BACKDROP, an unchanging, constant scene that will serve as a backdrop scene in some future problems. – its size should be WIDTH by HEIGHT pixels – it should include at least one visible unchanging image of your choice (and you may certainly include additional visible unchanging images if you wish). • (you may certainly include additional named constants, also, if you wish!) 5 part b Consider a “world” of type number — starting from a given initial number, in which that number changes as a ticker ticks, and in which the number determines what is shown where (or how) in a scene. For this world, big-bang’s to-draw clause will need a scene-drawing function that expects a number, and produces a scene based on that number. Don’t get too far ahead of yourself, here! Just decide what image(s) is/are going to be ADDED to your BACKDROP scene from 5 part a based on a number value. Do something that is at least slightly different than the posted class examples. (For example, an image could be placed in the BACKDROP whose size depends on that number — and/or an image’s x-coordinate within the BACKDROP could be determined by that number — and/or an image’s ycoordinate within the BACKDROP could be determined by that number — and/or an image’s color could be determined by that number — and/or some combination, letting it determine both the x- and y-coordinate, for example.) Write an appropriate signature comment for this function. 5 part c Write an appropriate purpose statement comment for this function. 5 part d Write an appropriate function header for this function (putting … ) for its body for now). 5 part e Write at least two specific examples/tests/check-expect expressions for this function, placed either before or after your not-yet-completed function definition, whichever you prefer. 5 part f Finally, replace the … in this function’s body with an appropriate expression to complete it. For full credit, make sure that you use your BACKDROP scene from 5 part a appropriately within this expression. Run and test your function until you are satisfied that it passes its tests and works correctly. Also include at least 2 example calls of your function (such that you will see their results) after your function definition. 5 part g What change do you want to happen to your world number as the world ticker ticks? Will it increase by 1?
CS 111 – Homework 3 p. 8
decrease by 1? Increase and/or decrease by varying amounts? Decide how your world number will change on each ticker tick. If your change can be done by a built-in function such as add1 or sub1, that is fine. Otherwise, using the design recipe, develop this function, that expects a number and produces a number. • (if you develop your own function here, REMEMBER to do all the steps you have been doing for the other functions in this homework — first write its signature, then its purpose statement, then its function header, then its tests/check-expect expressions, then replace its … body with an appropriate expression) Then write a big-bang expression consisting of an initial number, and a to-draw clause with the name of your scene-drawing function from 5 parts b-f, and an on-tick clause with the name of your (new or existing) number-changing function — something like: (big-bang initial-number-you-choose (to-draw name-of-your-scene-drawing-function) (on-tick name-of-your-number-changing-function)) (By the way, you can also change the speed of the ticker in this on-tick clause if you would like to — give it an optional 2nd expression, a number that is a ticker-rate-expression, and the ticker will tick every ticker-rate-expression seconds.) Now you should see something changing in your scene, and now you are done with this problem.

 

We give our students 100% satisfaction with their assignments, which is one of the most important reasons students prefer us to other helpers. Our professional group and planners have more than ten years of rich experience. The only reason is that we have successfully helped more than 100000 students with their assignments on our inception days. Our expert group has more than 2200 professionals in different topics, and that is not all; we get more than 300 jobs every day more than 90% of the assignment get the conversion for payment.

Place Order Now

#write essay #research paper #blog writing #article writing #academic writer #reflective paper #essay pro #types of essays #write my essay #reflective essay #paper writer #essay writing service #essay writer free #essay helper #write my paper #assignment writer #write my essay for me #write an essay for me #uk essay #thesis writer #dissertation writing services #writing a research paper #academic essay #dissertation help #easy essay #do my essay #paper writing service #buy essay #essay writing help #essay service #dissertation writing #online essay writer #write my paper for me #types of essay writing #essay writing website #write my essay for free #reflective report #type my essay #thesis writing services #write paper for me #research paper writing service #essay paper #professional essay writers #write my essay online #essay help online #write my research paper #dissertation writing help #websites that write papers for you for free #write my essay for me cheap #pay someone to write my paper #pay someone to write my research paper #Essaywriting #Academicwriting #Assignmenthelp #Nursingassignment #Nursinghomework #Psychologyassignment #Physicsassignment #Philosophyassignment #Religionassignment #History #Writing #writingtips #Students #universityassignment #onlinewriting #savvyessaywriters #onlineprowriters #assignmentcollection #excelsiorwriters #writinghub #study #exclusivewritings #myassignmentgeek #expertwriters #art #transcription #grammer #college #highschool #StudentsHelpingStudents #studentshirt #StudentShoe #StudentShoes #studentshoponline #studentshopping #studentshouse #StudentShoutout #studentshowcase2017 #StudentsHub #studentsieuczy #StudentsIn #studentsinberlin #studentsinbusiness #StudentsInDubai #studentsininternational