Programming Language BSL Purpose To design a small program using structured data.   Expectations You should submit a single .rkt file containing your responses to all exercises via the Handin Server. We accept NO email submissions. Failure to submit a .rkt file will result in a 0. You are only allowed to use the language specified at the top of this page: failure to do so will result in a 0. You should only use the concepts that we have covered in class so far. Your code MUST conform to the guidelines outlined in the style guide on the course website. The style guide will be updated as the semester progresses so please remember to read it before submitting each assignment. You must follow all the steps of the design recipe when completing this assignment.   Graded Exercises Exercise 1 Design a data definition for a mathematical expression. Your data definition should be able to handle the addition, subtraction, and multiplication of any two integers. You do not need to handle nested expressions such as (5 + 4) * 7. Be as specific as you can (do not say that a structure can take a String unless it can take any String. Be sure to follow all the steps of the data design recipe. Note: If your data examples look like "15+4" you are on the wrong track. You need a data definition that will easily allow you to work with your data, not just display it. Exercise 2 Design a function solver which, given a mathematical expression (the data you designed in the last exercise) produces an integer result. For example, given (5 + 4) the function should output 9. In the remainder of this assignment you will be designing a world program which allows the user to guess a random number in some range. The program will take in two numbers: the lowest possible number and the highest possible number. Then the game will start. The player can guess any integer (including negative integers) and will be provided with a response: either "too low!", "too high!", or "you did it!". The game will end when the player guesses the number correctly. Until then the player can keep guessing as many times as they like.   Exercise 3 Design a data definition for your world program. Keep in mind that your data definition should: NOT store the minimum or maximum answer as this information is not useful once the game has started. be as specific as possible (don’t use String unless you are expecting to need to handle any String). account for the case where the user has not yet made any guesses. Remember to follow all the steps of the data design recipe.     Exercise 4 Design the program. Here are some key things to note: The user can type any integer but they should not be able to type non-integers such as "3.14" or "5-6". However your program should not break if the user types an invalid key. It should simply ignore it. string-numeric? may be useful here. The game should display the instructions "type a number to guess" if the user has not yet made any guesses. Otherwise it should display the feedback from their most recent guess. It should also display the text the user is currently typing. The game should end when the user correctly guesses the number, but it should continue to display the screen with the text "you did it!". To do this you may need to look at the documentation for stop-when. The game should check the user’s answer after they press enter. The function string->number may be useful to you here. If the user has not entered any text they should still be able to press enter, but nothing will happen.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

 

Programming Language BSL

Purpose To design a small program using structured data.

 

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

  • You are only allowed to use the language specified at the top of this page: failure to do so will result in a 0. You should only use the concepts that we have covered in class so far.

  • Your code MUST conform to the guidelines outlined in the style guide on the course website. The style guide will be updated as the semester progresses so please remember to read it before submitting each assignment.

  • You must follow all the steps of the design recipe when completing this assignment.

 

Graded Exercises

Exercise 1 Design a data definition for a mathematical expression. Your data definition should be able to handle the addition, subtraction, and multiplication of any two integers. You do not need to handle nested expressions such as (5 + 4) * 7. Be as specific as you can (do not say that a structure can take a String unless it can take any String. Be sure to follow all the steps of the data design recipe.

Note: If your data examples look like "15+4" you are on the wrong track. You need a data definition that will easily allow you to work with your data, not just display it.

Exercise 2 Design a function solver which, given a mathematical expression (the data you designed in the last exercise) produces an integer result. For example, given (5 + 4) the function should output 9.

In the remainder of this assignment you will be designing a world program which allows the user to guess a random number in some range. The program will take in two numbers: the lowest possible number and the highest possible number. Then the game will start. The player can guess any integer (including negative integers) and will be provided with a response: either "too low!", "too high!", or "you did it!". The game will end when the player guesses the number correctly. Until then the player can keep guessing as many times as they like.

 

Exercise 3 Design a data definition for your world program. Keep in mind that your data definition should:
  • NOT store the minimum or maximum answer as this information is not useful once the game has started.

  • be as specific as possible (don’t use String unless you are expecting to need to handle any String).

  • account for the case where the user has not yet made any guesses.

Remember to follow all the steps of the data design recipe.

 

 

Exercise 4 Design the program. Here are some key things to note:
  • The user can type any integer but they should not be able to type non-integers such as "3.14" or "5-6". However your program should not break if the user types an invalid key. It should simply ignore it. string-numeric? may be useful here.

  • The game should display the instructions "type a number to guess" if the user has not yet made any guesses. Otherwise it should display the feedback from their most recent guess. It should also display the text the user is currently typing.

  • The game should end when the user correctly guesses the number, but it should continue to display the screen with the text "you did it!". To do this you may need to look at the documentation for stop-when.

  • The game should check the user’s answer after they press enter. The function string->number may be useful to you here. If the user has not entered any text they should still be able to press enter, but nothing will happen.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY