Check for Mistakes in this Word Problem: flower-name
Directions: You are putting together a list of flowers in your garden based on their color. You have red roses, purple tulips, and yellow daisies.
Write a function that takes in the color of a flower and returns the name of the flower.
Contract and Purpose Statement
Every contract has three parts ...
;flower-name:string→string
; Takes the name of the flower and returns its color
Examples
Write some examples, then circle and label what changes ...
(EXAMPLE (flower-name"red")"rose"
(EXAMPLE (flower-name"tulip")"purple"
(EXAMPLE (flower-name"yellow")"daisy"
Definition
Write the definition, giving variable names to all your input values ...
(define (flower-namecolor)(
cond[
(string=? color "red")"rose"
[(string=? color "purple")"tulip"
[(string=? color "yellow")"daisy"
[else"That flower isn’t in the garden!"