6.6

Assignment 1

home work!

Programming Language BSL

Due Date Thursday 9/13 at 9pm

Purpose To write simple functions & tests relating to numbers, images, and strings

Expectations
  • You should submit a single .rkt file containing your responses to all exercises via the Handin Server. We accept NO email submissions.

  • You are only allowed to use the language specified at the top of this page: failure to do so will result in a 0.

  • Function signatures/purpose statements are not required, but attempting them would be good practice and you may receive useful feedback for future assignments.

Graded Exercises

Please download the starter file before beginning this assignment. Right click the file and choose "Save link as..." to save it. Do NOT try to copy the code from the file into DrRacket since the file contains images which cannot be copied over easily. You should complete the assignment in this file so that you can use our provided tests.

Exercise 1 Write a function, octuple, that multiplies a number, supplied as an argument, by 8. Write three check-expects: one for a negative value, another for zero, and a third for a positive value.

Exercise 2 Jill is about to start her first year at the Hogwarts School of Witchcraft and Wizardry, and so she wants to convert her muggle currency (Pounds Sterling) to something more useful, Galleons. While shopping in Diagon Alley, she happens upon a currency-exchange service that provides the following chart...

Notice that there is a flat fee charged for service as well as a conversion rate for each Pound -> Galleon. For example, it takes 8 Pounds to get your first Galleon, but then only 13 to get your second.

Write a function, diagon-convert, to convert from Pounds to Galleons. Write four check-expects: two match the examples described above, one that is shown in the graph, but not described, and one that is a value greater than those shown in the graph. Note: one of these must result in a non-integer for credit.

Hint: it can be useful to write out a table of input/output pairs to help understand these types of mathematical relationships (and these can then provide great tests!)

Exercise 3 Write a function, logo-gen, that generates a simplified version of the Microsoft logo of any size. We have provided two check-expects to help you test your function in the starter file for this assignment.
  • The side length of each internal square is supplied as an argument to the function.

  • The colors are "red", "forest green", "light blue", and "orange".

  • There is no space between or outside each square.

Exercise 4 For any word of at least one character that starts with a letter, let’s say that its "bingo word" is the uppercase version of the first letter, followed by a space, and then followed by the number of characters in the word. For example, the bingo word of "bingo" is "B 5" and the bingo word of "Win" is "W 3".

Write a function, bingo-word, that takes a string as an argument and returns its bingo word. You may assume that the argument is a valid word as described above. Write three check-expects: the two examples above, as well as one of your choosing: be creative, but respectful :)

Hint: The String function documentation is a useful place to look for functions that operate on Strings.