Written by Bryce Cronkite-Ratcliff Julia Lee, TY Huang and Chris Piech.
Handouts: Graphics Reference, ArrayList Reference, Karel Reference
Sandcastles may be short-lived, but they're fun and beautiful, just like this collection of small problems. Complete these problems individually.
Karel loves stairs! Make a diagonal line of blue corners across the world. You may assume the world is square.
Print out the number sequence 0, 5, 10, 15, 20, 25... Print 20 numbers in all.
The user (an earthling) enters his or her weight on earth. Your program will print the user`s weight on the moon, which is 16.5% of his or her weight on earth.
Print 30 randomly generated numbers using a RandomGenerator.
Add 2 GRects and 2 GOvals to the screen (any size or color). If the user clicks any of the GObjects, it should be removed from the screen.
Write a method that returns a boolean indicating whether an integer (provided as a parameter) is your favorite number or not (choose your favorite number if you don`t have one already!!). Use this method to write a program that accepts an integer and tells the user if the integer is your favorite number.
Generate a random integer between 0 and 100. Ask the user to guess the random number. Tell the user if their guess is too high, too low, or correct. Continue asking for guesses until the user guesses the correct number.
Accept input from the user. Keep track of the sum of all the numbers you have seen so far and print that sum to the user.
Draw a staircase! Use GRects and a double for loop to draw the image below. Do not fill the GRects. Hint: There is a first row with 0 GRects.
Fill in the provided method so that it takes in an income and returns the corresponding amount of tax (in YTL) that is collected (a double).
The percentage you are taxed is based off of your income, as shown in the table below:
The Tax Base (YTL) | Tax % |
---|---|
0-20.000 | 15 |
20.001 or greater | 20 |
Draw 5 GOvals. Using an ArrayList, make the GOvals grow bigger forever.