Welcome to the lab 2!
Our goal today is to become more familiar with user interaction and the various mathematical operations.
Person A, take control of the machine!
Let’s write a program that prompts the user for two colors and mixes them together. This sort of routine is used all the time when resizing or transitioning between images.
A color is often represented in a computer with a triplet integers: a red component, a green component, and a blue component, each in the range [0, 255]. These three intensities combine to produce all the possible colors that our monitors can display.
To mix two colors, we compute a weighted average of their red components, green components, and blue components separately to produce a new triplet.
Follow these steps to write your color-mixing program:
ints, one for each of the color’s red, green, and blue intensities. Assume the color intensities are in [0, 255]. Pick good names for your variables!
ints. Pick good names for your variables!
Person B, take control of the machine!
With person A at your side, we’ll write two little games. These exercises are intentionally designed to be more open-ended. We are happy to help you if you can’t figure out how to achieve your goal, but we don’t want to rob you of the learning that happens naturally when fewer directions are given.
Write a little game we’ll call
Pause. The rules of the game are this:
A possible interaction might look like this:
Wait 4.3 seconds... You waited 5.76323 seconds. That's 1.46323 seconds too many.
The students at my children’s elementary school do a math exercise called Math Mountain. They are presented a number at the “peak” of the mountain, and another number at its left base. They are to enter the number at its right base, such that the two bases sum to to the peak. A prompt might look like this on their worksheet:
24 17 __
A student would enter 7 as the answer because 17 + 7 = 24.
Write a program that lets the user complete one or more rounds of Math Mountain.