Mini-Project:
Setters, Getters, Math
07
Getting Started
A. Download the Starter Code
B. In AppInventor, click on the Projects drop down menu
select "Import project (.aia) from my computer…"
choose the .aia file you just download and press ok
For each of the following problems, code the solution in the Blocks Editor. Then run and test your solution. Keep running and testing until you are certain that it is correct. Each problem should have its solution displayed in the specific label for it.
Goals & Requirements
0. Rename the Screen1.Title to your name.
1. Repeat the input. Put together code in the blocks editor that will simply repeat in the label whatever the user has input into the text box when the top Test it! button ButtonTestWord is clicked.
2. Prettify the output. Modify your solution blocks to the previous exercise so that it joins "Hi, you typed" to the user's input and displays it.
3. Quotify the user's input. Modify your solution blocks to the previous exercise so that it puts quote marks around the user's input.
Note: The period should be inside the quotes.
4. Add 5 to the input number. Make is so that when a user inputs a number and then presses Test it 2! the app will add 5 to the user's input and display the result as shown.
NOTE: The NumbersOnly property is set to true for TextBoxNumber.
5. Add a random value. Modify the previous exercise so that, instead of 5, it will add a random number between 1 and 10 to the user's input and displays the result as shown.
In order to get the same random number displayed and added: you will need to first set a local variable to a random number, then use that variable for both the display and the result.
6. Add a random value twice. Modify your solution to the previous exercise so that it adds the random value twice: e.g., 7 + 9 + 9 = 25
7. Compute the quotient. Create the following interface so that when the user inputs two numbers the Test It 3! button will correctly compute the quotient a/b. Note: add the following components and name correctly: label for x, textbox for x, label for y, textbox for y, button, label for output.
8. Compute the remainder as well. Input two values, x and y and compute and display the remainder of x divided by y: i.e., x mod y.
HINT: Look for the modulus/remainder block in the Math drawer.
You will also need to round down the result of the division, and to do so you can use the floor command.
9. Calculate the Hypotenuse. Add another row for inputs a and b which represent the sides of a right triangle. Then use the Pythagorean formula for calculating the length of the hypotenuse where h = sqrt(a^2 + b^2), to calculate and report the hypotenuse as shown.
Two good test cases are 3, 4, and 5. That is, if the sides are 3 and 4, the hypotenuse will be 5. Another Pythagorean Triple is 5, 12, and 13. If the sides are 5 and 12, the hypotenuse will be 13, as shown.
Note: there should be a space after the 6.
Entire completed app should look very similar to the picture shown.
10. Extra Credit: Style the app nicely. Make the app have a better style. One hint could be to have each test section a different color.
Be creative!
Show TClark your completed app, then turn in all the files in the form.