Write an appropriate signature comment for order-price

Assignment Help Computer Engineering
Reference no: EM131380856

Assignment

Purpose

To practice defining and using named constants, and to practice using the design recipe to write and test functions.

How to submit

Each time you would like to submit your work:

• save your current Definitions window contents in a file with the name 111hw2.rkt

- Note: please use that *exact* name -- do not change the case, add blanks, etc. If I search for a file with that name in your submission, I want it to show up! 8-)

• transfer/copy that file to a directory on nrs-labs.humboldt.edu (preferably in a folder/directory named 111hw2)

- If you are in a campus lab, you can do so by copying them to a folder on the U: drive
- If you are not in a campus lab, you can do so by using sftp (secure file transfer) and connecting to nrs-labs.humboldt.edu, and then transferring them.

Graphical versions of sftp include WinSCP and Secure Shell Transfer Client for Windows, Cyberduck and Fugu for Mac OS X, and FileZilla that has versions for both Windows and Mac OS X. (Mac OS X and Linux also come with a command-line sftp -- an intro to this is included in the posted handout, "useful details - sftp, ssh, and ~st10/111submit", available on the public course web site in the References section and in the Homework 1 section.)

- Whichever version of sftp you are using, use a host name of nrs-labs.humboldt.edu if you are not in a campus lab (you can get away with just nrs-labs for the host name in a campus lab), your campus username, and when you are prompted for it, your campus password. IF you need to give a port number, give a port number of 22.

• Now that your file is on nrs-labs.humboldt.edu, you need to log onto nrs-labs.humboldt.edu using ssh, so you can submit your file to me.

- In BSS 313, the Windows computers have a graphical version of ssh called PuTTY. There is a graphical version of ssh for Mac OS X named Jelly FiSSH, (although Mac OS X and Linux also come with command-line ssh, and an intro to this is also included in the "useful details - sftp, ssh, and

~st10/111submit" handout.)

- Again, whichever version of ssh you are using, use a host name of nrs-labs.humboldt.edu if you are not in a campus lab (you can get away with just nrs-labs for the host name in a campus lab), your campus username, and when you are prompted for it, your campus password. IF you need to give a port number, give a port number of 22.

• WHILE you are logged onto nrs-labs:

- IF you saved your file in a folder, use cd to change to the folder/directory where you saved it -- for example, if you saved it in the folder 111hw2, then you would go to that directory by saying:

cd 111hw2

- use the ls command to make sure your 111hw2.rkt file is really there:

ls

- type the command:

~st10/111submit

...and when asked, enter a homework number of 2

...and when asked, enter y, you do want to submit all files with an appropriate suffix (I don't mind getting some extra files, as long as I also get 111hw2.rkt; I'd rather receive too many files than too few due to typos.)

...make sure to carefully check the list of files submitted, and make SURE it lists 111hw2.rkt as having been submitted! (The most common error is to try to run ~st10/111submit while in a different directory than where your files are...)

• (we practiced the above during the Week 1 Lab, on Friday, January 20 -- ASK ME if this is still not clear, or if you have any problems with submission! If you get stuck, E-MAIL me your 111hw2.rkt file as an e-mail attachment before the deadline, AND then ALSO submit it as soon after that as you are able.)

- I am happy to walk through submitting files with you -- just come by my office during office hours, or e-mail me to set up an appointment.

Important notes

• Signature and purpose statement comments are ONLY required for function definitions -- you do NOT write them for named constants or for non-function-definition compound expressions.

• Remember: A signature in Racket is written in a comment, and it includes the name of the function, the types of expressions it expects, and the type of expression it returns. This should be written as discussed in class (and you can find examples in the posted in-class examples). For example,

; signature: purple-star: number -> image

• Remember: a purpose statement in Racket is written in a comment, and it describes what the function expects and describes what the function returns (and if the function has side-effects, it also describes those side-effects). For example,

; purpose: expects a size in pixels, the distance between
; points of a 5-pointed-star, and returns an image
; of a solid purple star of that size

• Remember: it is a COURSE STYLE STANDARD that named constants are to be descriptive and written in all-uppercase -- for example,
(define WIDTH 300)

• You should use blank lines to separate your answers for the different parts of the homework problems. If you would like to add comments noting which part each answer is for, that is fine, too!

• Because the design recipe is so important, you will receive significant credit for the signature, purpose, header, and examples/check-expects portions of your functions. Typically you'll get at least half-credit for a correct signature, purpose, header, and examples/check-expects, even if your function body is not correct (and, you'll typically lose at least half-credit if you omit these or do them poorly, even if your function body is correct).

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 2,
• 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 2
; last modified: 2017-01-30
;

Below this, after a blank line, now type the comment lines:
;
; Problem 1
;

And PLEASE NOTE -- you are not defining ANY new functions in this problem, you are practicing writing and using a named constant, and practicing writing some check-expect compound expressions.

1 part a

Remember the image you created for Homework 1, Problem 7? Write a Racket define expression to define a named constant whose value is that image.

NOTE: You are probably more familiar with more image operations now than you were when completing Homework 1 -- as long as you still meet the requirements from Homework 1, Problem 7, you can change your image IF you would like. If you do create a different image, I will use Homework 2's version in the "class quilt" unless I hear from you otherwise.

As a reminder, here are those requirements:

• the final resulting image somehow should be the result of at least THREE different image or image- related operations from the 2htdp/image teachpack. (More is fine!)

- They can be image operations from the "Some DrRacket Tidbits" handout, OR they can be image operations (from the 2htdp/image teachpack) that you find by exploring DrRacket's Help feature, described a bit at the end of the "Some DrRacket Tidbits" handout.

• the final resulting image should be an expression of type image that is precisely 200 pixels wide and 200 pixels high

- You might ask -- how can I be SURE my final image is the right size? The function image-width expects an image arguments, and returns its width in pixels -- and the function image-height expects an image argument, and returns its height in pixels. So, you can use these functions to check the width and height of your final image, IF you would like.

• ACCEPTABLE "extended" version of this problem: IF you would like to use define to also give names to some ADDITIONAL expressions to make your task easier, that is allowed and encouraged (but not required) for this problem.

• As long as you meet the above requirements, your image may be as simple or as complex as you would like.

1 part b

Recall that Homework 1, Problem 7 specified that this image needed to be "precisely 200 pixels wide and 200 pixels high". You're now going to test that this is the case.

Recall that operation image-width expects an image and returns its width in pixels, and that operation image-height expects an image and returns its height in pixels. Write TWO check-expect expressions:

• Write a check-expect expression, using image-width and your named constant from Problem 1 part a, that will pass if your named constant image is indeed 200 pixels wide.

• Then, write a second check-expect expression, using image-height and your named constant from Problem 1 part a, that will pass if you named constant image is indeed 200 pixels high.

(What if you find out your image isn't 200 x 200 pixels? Then you should modify your named constant definition in Problem 1 part a so that it is.)

Problem 2

Next, in your definitions window, after a blank line, type the comment lines:
;
; Problem 2
;

Now, you are defining a new function! Consider a function that is to return the perimeter of a square.

2 part a

How many and what type of expressions should such a function expect, to be able to return such a perimeter?

Decide on a good, descriptive name for this function, and 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).

2 part d

Write at least 2 specific tests/check-expect expressions for this function. Interestingly, you may actually place these either before or after your not-yet-completed function definition, whichever you prefer.

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
;

Consider a function that asks a given person how their day is going. Given a person's name, it returns How's it going, ...that person's name... ? (Optionally, you may change the exact wording of the question, as long as it includes the person's name and ends with at least one question mark.)

3 part a

How many and what type of expressions should such a function expect, to be able to return this question?

Decide on a good, descriptive name for this function, and 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 two specific tests/check-expect expressions for this function, placed either before or after your not-yet-completed function definition, whichever you prefer.

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

Next, in your definitions window, after a blank line, type the comment lines:

;

; Problem 4
;

You decide it would be useful to be able to take some title text and an image, and create a new image that includes the given title above that image, such that the title text is depicted in 25-pixel-high black letters that are actually part of the image.

4 part a

Decide on a good, descriptive name for this function, and 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 two specific tests/check-expect expressions for this function, placed either before or after your not-yet-completed function definition, whichever you prefer.

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, after a blank line, type the comment lines:

;
; Problem 5
;

Consider a function total-inches that expects a number of feet and a number of inches, and returns the total number of inches. (For example, the value of the expression (total-inches 4 5) should be 53, because 4 feet and 5 inches is 53 inches overall.)

5 part a

This part comes BEFORE starting function total-inches!

FIRST: write a Racket definition for a named constant that will define the name IN-PER-FT to be the number of inches in a foot. (IN-PER-FT is NOT a function! It is just a number, the number of inches in a single foot.)

5 part b

NOW you are starting the design recipe for function total-inches.

NOW, write an appropriate signature comment for the function total-inches.

5 part c

Write an appropriate purpose statement comment for total-inches.

5 part d

Write an appropriate function header for total-inches (putting ... ) for its body for now).

5 part e

Write at least two specific tests/check-expect expressions for total-inches,

• at least one for a number of feet of 0, and
• at least one for a number of feet greater than 1,
• (each with a DIFFERENT number of inches),

...placed either before or after your not-yet-completed function definition, whichever you prefer.

5 part f

Only NOW should you replace the ... in total-inches's body with an appropriate expression to complete it. For full credit, make sure that you use the named constant IN-PER-FT appropriately within this expression.

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 6

Next, in your definitions window, after a blank line, type the comment lines:

;
; Problem 6
;

(This is adapted from Homework 1 of J. Marshall's "The Way of the Program" course at Sarah Lawrence College.)
The Tasty-Waking coffee roasters sells whole-bean coffee at $8.95 per pound plus the cost of shipping. Each order ships for $0.85 per pound plus $2.25 fixed cost for overhead.

(So, if someone buys 1 pound of their whole-bean coffee, the total price is $12.05; if someone buys 2 pounds of their whole-bean coffee, the total price is $21.85; if someone buys 5 pounds, the total is $51.25.)

6 part a

The description above includes three constant, unchanging values. Define an appropriate, descriptive named constant for each of these values.

6 part b

Now consider a function order-price whose purpose is to calculate the total price for an order. Given that you already know the values for the named constants given in Problem 5 part a, how many and what type of additional expressions should such a function expect, to be able to calculate the price of a coffee order?

Write an appropriate signature comment for order-price.

(Hint: don't include named constants in the signature! Only consider what the function needs BESIDES the named constants to complete the task.)

6 part c

Write an appropriate purpose statement comment for this function.

6 part d

Write an appropriate function header for this function (putting ... ) for its body for now). (Hint: remember that named constants do not belong in a function header, either.)

6 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.

6 part f

Finally, replace the ... in this function's body with an appropriate expression to complete it. For full credit, make sure that NOW you use the named constants 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.

Finally, include at least 2 example calls of your function (such that you will see their results) after your function definition.

Problem 7

Next, in your definitions window, after a blank line, type the comment lines:

;
; Problem 7
;

Decide on a function that will take one or more parameters and return an image as a result. It can be anything not yet written in class or on a previous homework problem (variations on functions done in class or a homework problem are fine).

7 part a

Decide on a good, descriptive name for your function, and write an appropriate signature comment for this function.

7 part b

Write an appropriate purpose statement comment for this function.

7 part c

Write an appropriate function header for this function (putting ... ) for its body for now).

7 part d

Write at least two specific tests/check-expect expressions for this function, placed either before or after your not-yet-completed function definition, whichever you prefer.

7 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.

Reference no: EM131380856

Questions Cloud

Create a project using the arraylist class : Create a project using the ArrayList class and the Main class in Search Algorithms. The ArrayList class contains implementations of the first three search methods explained in this week's lecture: sequential, sorted, and binary search.
Sustainability portfolio into the companys strategy : Examine the possible advantages and difficulties in integrating your sustainability portfolio into the company's strategy - design a sustainability plan for that company - If the company already has a clear sustainability portfolio, analyse it accor..
Discuss difference between a proactive and a reactive firm : Discuss the difference between a proactive and a reactive firm.- Discuss the impact of the Internet and e-commerce in making a firm global.
What kind of investment is most beneficial to a country : Explain the difference between franchising, licensing, and foreign direct investment, in terms of ownership, control, and risk.
Write an appropriate signature comment for order-price : CS 111- Write an appropriate signature comment for order-price. How many and what type of expressions should such a function expect, to be able to return such a perimeter?
Alternative expansion strategies for damar international : Evaluate alternative expansion strategies for Damar International in the United States.- Discuss Damar's expansion alternatives in Indonesia and France and their implications for the U.S. market.
Business process modelling : Advice to the business owner on how their business has performed for the month of December with particular focus on the profitability of the business.
Working for and against lakewood forest products : What are the environmental factors that are working for and against Lakewood Forest Products both at home in the United States and in the target market, Japan?
What marketing approaches could green mountain adopt : What marketing approaches could Green Mountain adopt in order to expand its customer base?- How do international and domestic events affect Green Mountain's marketing strategy and sales?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Assignment program crawler game

Assignment program Crawler game: Update the Crawler game attached to allow a user to traverse the Cave. They should be prompted in each room to pick an exit or quit

  Include the declaration in a program

Write down a declaration to store the string "This is a sample" in an array named samtest. Include the declaration in a program that displays the values in samtest in a for loop that uses a pointer to access each element in the array.

  Perform the tasks below by using the correct sql statements

perform the tasks below by using the correct sql statements. you must create the statements in oracle by using the

  Implement the augmented lagrange multiplier method

Write a computer program to implement the augmented Lagrange multiplier method with a suitable method of unconstrained minimization.

  Write down a c program that takes an integer argument

Write a C program that takes an integer argument from command line and outputs the sum of all digits of the integer. For in case , the result of the invocation sum of digits 12345 should be 15.

  Show the command line and accept one interger as input

Call a function the outputs seven sequential intergers, with input interger as the middle item on the command line below the input prompt.

  What is joptionpane class or the scanner class

What is JOptionPane class or the Scanner class

  Establish a formal evaluation criterion

Why would it be wise to build a formal evaluation criterion for a company to use when purchasing new hardware or software.

  Questionour program has to take a string representing a

questionour program has to take a string representing a sentence in english and format it properly. the input sentence

  Example of a software quality problem

From your experience give an example of a software quality problem that was identified after the software was released. Why was this problem not identified earlier?

  Explain time and space complexity in details

What do you mean by performance of algorithm explain time and space complexity in details?

  Questionsomeone once observed that the difference between

questionsomeone once observed that the difference between roles and groups is that a user be able to shift into and out

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd