Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Racket language (@problem 1) ;; ;; The following function design may have errors in it. Please fix the error ;; or errors that you find.

Racket language

(@problem 1) ;; ;; The following function design may have errors in it. Please fix the error ;; or errors that you find. Any changes you make should preserve the existing ;; design intent. So, for example, if you can fix the design to be consistent ;; and work properly by making 1 change or by making 5 changes then usually ;; the 1 change version is the correct fix. ;;

(@htdf more-characters?) (@signature String Natural -> Boolean) ;; produce true if the number of characters in s is greater than n (check-expect (more-characters? "cpsc" 3) true) (check-expect (more-characters? "cpsc" 4) false) (check-expect (more-characters? "cpsc" 5) false) (check-expect (more-characters? "programming" 4) true)

;(define (more-characters s n) false) ;stub

(@template String)

(define (more-characters? s n) (> string-length n))

(@problem 2) ;; ;; The following data design may have errors in it. Please fix the error ;; or errors that you find. Any changes you make should preserve the existing ;; design intent. So, for example, if you can fix the design to be consistent ;; and work properly by making 1 change or by making 5 changes then usually ;; the 1 change version is the correct fix. ;;

(@htdd Season) ;; Season is one of: ;; - "Winter" ;; - "Spring" ;; - "Summer" ;; - "Autumn" ;; interp. one of the four seasons in a year ;;

(@dd-template-rules atomic-distinct atomic-distinct atomic-distinct atomic-distinct)

(define (fn-for-season s) (cond [(string=? s "Winter") (...)] [(string=? s "Spring") (...)] [(string=? s "Summer") (...)] [(string=? s "Autumn") (...)]))

(@problem 3) ;; ;; For any particular racer in an event their result can reflect that they did ;; not start the race, did not finish the race, or the time it took them to ;; complete the race. ;; ;; Design a data definition to represent such race results. ;;

(@problem 4) ;; ;; Use your data defintion from Problem 3 to complete this problem. ;; ;; Design a function that consumes a race result and determines whether the ;; racer completed the race. Be sure to follow all design rules, including ;; the rule about preserving all cond cases in a template in all functions. ;;

(@problem 5) ;; ;; Use your data defintion from Problem 3 to complete this problem. ;; ;; Design a function that consumes a race result and the previous world record ;; time for the race. The function should produce the new world record. The ;; world record is only changed when a racer completes a race in a LOWER time. ;;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What have you done that shows initiative and willingness to work?

Answered: 1 week ago