Assignment 12
Due Tuesday, February 22 at 11:20am on Canvas


Assignment 12.1: Rock Paper Scissors (10 pts)

  • Write a program to simulate a Rock, Paper, Scissors competition between two players.
  • Your file should be named RPS.java and should be uploaded to Canvas when you are finished.
  • First, the program will welcome them to the competition.
Let's play Rock-Paper-Scissors!
  • Then, the program will prompt each user to enter his or her name.
Player one, please enter your name: _
  • Next, the program will ask each user (referring to him or her by name) to enter "Rock," "Paper" or "Scissors."
Jorge, please enter "Rock", "Paper" or "Scissors": _
  • Important: Note the use of the player name above and the " marks.
  • The program will determine who the winner is and output one of three options:
Rock breaks scissors!
Paper covers rock!
Scissors cut paper!
  • How will the program determine the winner? Hint: if - else if - else statements and using logical operators (&&, ||, !).
  • After outputting the above statement, the program will announce the winner by name:
Jorge wins!
  • In the case of a tie, the program should announce that the result is a draw.
The game is a tie.
  • Important: You are required to use logical operators (&&, ||, !) as part of your if  and else if statements.
  • The program should also prompt the user to decide if they want to play again (Hint: use a while loop).
  • Your program should work identically to the following examples:


Rock-Paper-Scissors Round 1!

Player one, please enter your name: Jorge
Player two, please enter your name: Jennifer
Jorge, enter "Rock", "Paper", or "Scissors": Rock
Jennifer, enter "Rock", "Paper", or "Scissors": Scissors
Rock breaks scissors!
Jorge wins!

Do you want to play again (y/n): y

Rock-Paper-Scissors Round 2!

Player one, please enter your name: Jorge
Player two, please enter your name: Jennifer
Jorge, enter "Rock", "Paper", or "Scissors": Scissors
Jennifer, enter "Rock", "Paper", or "Scissors": Scissors
It's a tie!

Do you want to play again (y/n): y

Rock-Paper-Scissors Round 3!

Player one, please enter your name: Wen
Player two, please enter your name: Amelia
Wen, enter "Rock", "Paper", or "Scissors": Rock
Amelia, enter "Rock", "Paper", or "Scissors": Paper
Paper covers rock!
Amelia wins!

Do you want to play again (y/n): n
Thanks for playing!


Assignment 12.2: What's Your Sign? (10 pts)
  • For this assignment, let's write an astrology program (Astrology.java).
  • Welcome the user (see sample output below)
  • Prompt the user to enter a numerical value (1-12) for the month of his/her birth (see sample output)
  • Prompt the user to enter a numerical value (1-31) for the day of his/her birth (see sample output)
  • Then, determine the user's sign based on their input.
        Aries                March 21-April 19
        Taurus             April 20-May 20
        Gemini            May 21 - June 21
        Cancer            June 22 - July 22
        Leo                  July 23 - August 22
        Virgo                August 23 - September 22
        Libra                September 23 - October 22
        Scorpio            October 23 - November 21
        Sagittarius       November 22 - December 21
        Capricorn        December 22 - January 19
        Aquarius         January 20 - February 18
        Pisces            February 19 - March 20
  • Your program must include a while loop to allow the user to repeat the calculation for another date of birth.
  • Expect to need to use if, else if and else statements.
  • Expect to use logical operator(s) (&&, ||, !).
  • Expect your test conditions to involve 3 boolean operators per test condition.
  • Submit to Canvas when you are finished.

Your sample output must be identical to mine:



Assignment 12.3: Hickory Dickory Dock Again (10 pts)
  • Open up Hickory.java from assignment 11.
  • Alter the program to use a for loop instead of a while loop
  • When you are finished, and your output looks like mine, upload your assignment to Canvas.
Your Output Should Look Like the Following. Note that some values have been omitted for brevity.
1
2
Hickory!
4
Dickory!
Hickory!
7
8
Hickory!
Dickory!
11
Hickory!
13
14
Dock! The Mouse Ran Up the Clock!
16
17
Hickory!
19
Dickory!
Hickory!
22
...
149
Dock! The Mouse Ran Up the Clock!