Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Has to compile in jGrasp. HAS TO INPUT(from a.txt file) and THIS CANNOT BE USED: import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; Rock, Paper, Scissors is

Has to compile in jGrasp. HAS TO INPUT(from a.txt file) and THIS CANNOT BE USED:

import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; 

Rock, Paper, Scissors is a two player game, where each player simultaneously chooses one of the three items after counting to three. The game typically lasts a pre-determined number of rounds. The player who wins the most rounds wins the game. Given the number of rounds in which the players will compete, it is your job to determine which player wins after those rounds have been played.

The rules for what item wins are as follows:

Rock always beats Scissors (Rock crushes Scissors)

Scissors always beat Paper (Scissors cut Paper)

Paper always beats Rock (Paper wraps Rock)

Input (from file a.txt)

The first value in the input file will be an integer t (0 < t < 1000) representing the number of test cases in the input file. Following this, on a case by case basis, will be an integer n (0 < n < 100)

CSCD210 Programming Principles I 2/14/2014

specifying the number of rounds of Rock, Paper, Scissors played. Next will be n lines, each with either a capital R, P, or S, followed by a space, followed by a capital R, P, or S, followed by a newline. The first letter is Player 1s choice; the second letter is Player 2s choice.

Output (to monitor)

For each test case, report the name of the player (Player 1 or Player 2) that wins the game, followed by a newline. If the game ends up in a tie, print TIE.

Sample Input

3 2 RP SR 3 PP RS SR 1 PR

Sample Output

Player 2 TIE Player 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

ISBN: 1285427106, 978-1285427102

More Books

Students also viewed these Databases questions