Part A: (5 Marks)

1. Write a program that lets the user play the game of rock, paper, scissor against the computer. The Program should work as follows
a. The program should start with giving user an option that if he wants to play the game (yes/no). If the user selects yes, the game should start, otherwise it should terminate.
b. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen the rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Do not display the computer choice yet)
c. The user enters his/her choices of “rock”, “paper”, or “scissors” at the Keyboard.
d. The computer’s choice is displayed
e. A winner is selected according to the following rules
• If one player chooses rock and the other player chooses scissors, then the rock wins. (The rock smashes the scissors)
• If one player chooses scissors and the other player chooses paper, then scissors wins. (Scissors cut the paper)
• If one player chooses rock and the other player chooses paper, the paper wins. (the paper wraps the rock)
• If both players make the same choice, the game must be played again to determine the winner.
f. After the game finishes it should give user an option again that if he wants to play (yes/no)

Part B: (5 Marks)

Create a class called Donor which represents a donor to an organization. It stores the donor’s name, amountDonated and rating.

Donor ratings is calculated based on the following schedule

• a) amt = 0 – none
• b) amt < \$100 – low level
• c) amt >= \$100 and amt < \$1000 – medium level
• d) amt >= \$1000 – high level

Add the following methods to the class

1. A constructor for the class Donor
2. getName() method to get the name of the Donor
3. getRating() to get the rating of the Donor
4. set.name() to ensure that the name only contains characters
5. set.amountDonated()to ensure that the amountDonated only contains numbers
6. set.rating() to ensure that the ratings can be set only to “none”, “low”, “medium” and “high”
7. set.ratings()
8. DonateAmount() donate more money as a donor
9. updateRatings() To Update the rating for the donor every time the donation is made.
10. DisplayDetails() Display all the properties for Donor

Create a driver program in a script file

1. Create three Donor objects with the following properties
Object Name amountDonated rating
D1 Ahmed 0 None
D2 John 100 Low
D3 Ali 900 Medium
2. Call Donate amount for each object with the following amount

Object amountDonated
D1 500
D2 1000
D3 2000

1. Call updateRatings method for each object to update the ratings based on the new donations.
2. Call DisplayDetails() for each donor to display the current status for the donor. NOTE: Submit the program codes and screenshots of the tests

Sample Solution