Application and Extension of Knowledge 1. The Law of Trichotomy states that for any two numbers, exactly one of these relationships is true: the first number is greater than the second number, less than the second, or equal to the second. Trichotomy means three choices or y parts. Create a Scratch project to illustrate this law. Ask the user to enter two numbers. Write nested IF…THEN…ELSE statements to reply to the user one of the three possible relationships dictated by the law. Test each path of the project and correct any errors. Save the project as AEK05-01 in your working folder. 2. Create an interactive game in Scratch in which a player is given a situation and asked the question “Should I stay or should I go?” The user must respond with either stay or go. For example, the situation may be a fire in the house, and the user is asked if he or she should stay or go. If the answer is go, congratulate that response. If the answer is stay, tell the user the correct response is go, and explain why that is the correct response. Give the user five situations. Keep track of how many correct answers are given, and display the score at the end along with a rating: 5 is excellent, 4 is good, and so on. Save the project as AEK05-02 in your working folder. 3. Many countries around the world and the US military use the 24-hour clock for time. In this format, 3:15 a.m. is written as 0315. Noon is written as 1200, while 3:15 p.m. is written as 1515. Create a Scratch project that asks the user to input a time in the 24-hour format. The program should evaluate the user input. If the time is between midnight and 6 a.m., the sprite should say Good Morning. If the time is between 6:01 a.m. and noon, say Good Day. If the time is between 12:01 p.m. and 6:00 p.m., say Good Afternoon. If the time is between 6:01 p.m. and 11:59 p.m., say Good Evening. Check for valid user input. If the input is not a valid time, tell the user the range of valid entries. Save the project as AEK05-03 in your working folder. 4. Cramer’s rule can be used to find an exact result for the point of intersection of two lines. Swiss mathematician Gabriel Cramer (1704–1752) noticed there is a pattern for solving a system of equations that is independent of the specific lines in question. He found a simple calculation for any system of linear equations that has exactly one point as a solution. Cramer states that for a system of equations in standard form, AX + BY = C and DX + EY = F, a simple calculation yields the solution for X and Y. X = (CE BF) ÷ (AE BD) Y = (AF DC) ÷ (AE BD) Create a Scratch project that asks the user to input values for A, B, C, D, E, and F. Have the program calculate X and Y and then report to the user the (X, Y) coordinates of the solution. Also, have the program check if the divisor (AE BD) is equal to zero, and, if so, tell the user that the two lines do not intersect in exactly one point. Save the project as AEK05-04 in your working folder. Think about why Cramer’s rule does not handle parallel lines or same-line equations. 5. Create a Scratch project using nesting techniques that asks the user to enter a temperature. If the temperature is 90 or greater, have the sprite say “That is hot.” If the temperature is 60 or greater, but less than 90, the sprite should say “That is warm.” If the temperature is less than 60, have the sprite say “That is cool.” Save the project as AEK05-05 in your working folder. 122 Introduction to Computer Science: Coding Copyright Goodheart-Willcox Co., Inc.
Previous Page Next Page