Please remember to write your program in good programming style: choose meaningful names of variables and don't forget comments! Also, please read the problems carefully and implement them exactly.
Modify the RandomRectangles.java file so that the color of each rectangle is randomly selected among 5 different colors. See the Color API for color choices. Do not use Color.white as a possible color of a rectangle (unless you set a different background color).
Hint: randomly generate an integer between 0 and 5. Then use
the switch
statement to set the color based on the
integer. Test your program to make sure that all colors are picked
(approximately) with the same probability.
Click here for a demo.
deed
, eye
, or Bob
(there are
numerous web sites on palindromes, for instance Page O'Palindromes,
where you can find more examples).
Write a program that gets one word from the user and decides if it's a palindrome. Hint: break the input string in halves, reverse one half, and then compare them using the String comparison. You might need to handle the cases of even number of letters and odd number of letters separately. Your program must recognize palindromes that have upper-case letters in them (such as Bob or Abba).
Submit your test cases with your program (as a .txt file or write them in comments).
Your grade will depend on how many cases your program can handle. Removing just white spaces will earn you 3 points.
Your program must print out the three numbers and display the message indicating whether the user has won and, if yes, how much.
Run your program several times until the first win. How many tries did it take? Write down the answer in comments.