CSci 1301: Takehome 1

Due: Monday, October 15th at 11:59pm (no late work accepted)

Total: 30 points

This is individual work. You are not allowed to spend more than 6 hours on this test. This includes any reading that you do to help you solve the problems.

Make sure to write your name in the file(s) you submit. You may submit one or two files.

Use helper functions as needed. All your functions must have a signature, a description, and, whenever possible, check-expect tests.

Comments, helpful variable names, and good code style and formatting are a very important part of your grade. You don't have to look for the shortest solution, but you should eliminate unnecessary code repetition if possible (use helper functions).

Task 1 (10 points): results of a vote

Write a function passed? that takes four strings, each of which can be "Yes" or "No" (in this exact capitalization). The function determines if a vote has passed based on the majority of four votes. The vote passes when strictly more than a half of the four votes is a "Yes". If two votes are "Yes" and two "no", the vote fails. The function outputs a boolean: #true if the vote passed and #false if it failed.
Below are some test cases. More test cases are needed. You don't need to test all possible combinations, but definitely add some tests.


      (check-expect (passed? "Yes" "No" "Yes" "Yes") #true)
      (check-expect (passed? "Yes" "No" "Yes" "No") #false)
      (check-expect (passed? "No" "No" "No" "No") #false)
  
Assume that the data passed to the function is guaranteed to be "Yes" or "No"; no other inputs can possibly be passed to it.

Task 2 (20 points): fish animation

Your goal is to implement a swimming fish animation. Use this fish picture: fish image
Its background color is cyan, so use Racket color "cyan" for the background scene. Implement your program step-by-step, add helper functions as needed. There is a lot of repetitive math computations, so use helper functions and constants to make your code clear and easy to manage.
The scene size is fixed: the width is 400, the height is 200.
You don't need to implement repeated motion (such as a cycle).
In order to make the fish picture smaller scale it to 0.5 in your program using Racket scale function.

If something is not working, please comment it out and write comments about why you think it's not working and how you would be going about fixing it if you had more time. Make sure that the code you submit runs, even if it doesn't implement all of the functionality.

Your work will be graded based on:

Happy programming!

What to submit

Submit your solutions in one file on canvas. The file must be named with your last name. In a submission comment write the total time you spent on the test.


CSci 1301 course web site.