Write a program to score the paper-rock-scissors game. Each of two players enters either P, R, or S. The program then announces the winner as well as the basis for determining the winner: “Paper covers rock”, “Rock breaks scissors”, “Scissors cut paper”,

computer science

Description

Both of these classes should be placed inside a package named Program2.

 

Program 2a:   Write a program to score the paper-rock-scissors game.  Each of two players enters either P, R, or S. The program then announces the winner as well as the basis for determining the winner: “Paper covers rock”, “Rock breaks scissors”, “Scissors cut paper”, or “Draw, nobody wins”. The players must be able to enter either upper- or lower-case letters. If an invalid choice is entered, the player should be permitted to re-enter his choice as many times as needed. When one game finishes, the game should start over, as many times as the player wishes to play.

 

Name your class program2a, followed by your name – i.e., program2aBobSmith.

 

Program 2b:  A population of green crud has an unusual growth pattern: it doubles its size every five days exactly, starting from the fifth day. Hence, if a green crud population starts out as 10 pounds of crud, then on day 5 there are 20 pounds, on day 10 there are 40 pounds, and so on.

 

Day

1

2

3

4

5

6

7

8

9

10

11

Crud

10

10

10

10

20

20

20

20

20

40

40

 

 

Write a program that takes both the initial size of a green crud population (in pounds) and some number of days as input, and computes from that information the size of the population (in pounds) after the specified number of days. Note that the number of days might not be evenly divisible by 5.

 

Name your class program2b, followed by your name – i.e., program2bBobSmith.

 

Submitting Work:

Submit your work as a single zip file of both project folders on MyGCC.  See Dr. Al Moakar if you need help. Note that your program must be commented appropriately.

Be sure to submit the correct files the first time. You will be graded on the correctness of your program and general layout of your code (indentation etc.) according to the following scale. Remember that you must comment this program!

A program that does not compile or link may not be graded.

 

Rubric

Program 2a:

Category

Details

Points Possible

Correctness (40%)

Prompts user for both inputs

10

Re-prompts players on bad inputs

10

Correctly reports winner (“Player 1 wins, rock beats scissors”)

10

Allows user to replay game as desired

10

Comments (5%)

Commented appropriately

5

Organization (5%)

Uses proper tabs, line breaks, etc.

5

Total:   /50

Program 2b:

Category

Details

Points Possible

Correctness (40%)

Prompts user for initial crud weight and days

10

Calculates growth correctly

20

Reports total amount of crud

10

Comments (5%)

Commented appropriately

5

Organization (5%)

Uses proper tabs, line breaks, etc.

5

Total:  /50

 


Related Questions in computer science category