4. Problem 4: Bonus Points Saved 20 points possible Reset to Starter Code Problem Description In this problem, you will
Posted: Thu Jul 14, 2022 2:10 pm
4. Problem 4: Bonus Points
Saved
20 points possible
Reset to Starter Code
Problem Description
In this problem, you will write a program that determines theamount of bonus points given to each player based on theirperformance. A greater amount of bonus points is allocated to thewinning player if less turns are taken to complete the game. Forexample, a player is given 100 points for winning a game. However,a player is awarded 200 points for winning a game in less than 7turns (i.e., inclusive, or less than or equal to 7). A player isawarded 300 points for winning a game in less than 5 turns (i.e.,inclusive, or less than or equal to 5).
The programs need to include the transformInputToIndex(String)and calculateWinner(int [][]) methods. Plus a new method calledcalculateBonus(int [][]) method that calculates the points awardedto each player depending on the number of turns they made to win.This method will return an int with the points. Also, theprintResults(int) methods, needs to be updated toprintResults(int, int), where the paramteres are the winner of thegame, and the points awarded.
Input
You will receive (from the user) the following as input (inorder):
Processing
Examples
Input
Output
P1 A1P2 B2P1 A2P2 B1P1 A3P2 Finish
1 2 0
1 2 0
1 0 0
Game Over - Player 1 Wins
300 points
P1 B2P2 A1P1 B1P2 A2P1 C1P2 A3P1 Finish
2 1 1
2 1 0
2 0 0
Game Over - Player 2 Wins
200 points
P1 C3P2 A2P1 Finish
0 0 0
2 0 0
0 0 1
Game Over - Draw
P1 B2P2 C2P1 A1P2 C3P1 C1P2 A3P1 B1P2 A2P1 B3P2 Finish
1 1 1
2 1 2
2 1 2
Game Over - Player 1 Wins
100 points
Use Scanner class
Java, please
Saved
20 points possible
Reset to Starter Code
Problem Description
In this problem, you will write a program that determines theamount of bonus points given to each player based on theirperformance. A greater amount of bonus points is allocated to thewinning player if less turns are taken to complete the game. Forexample, a player is given 100 points for winning a game. However,a player is awarded 200 points for winning a game in less than 7turns (i.e., inclusive, or less than or equal to 7). A player isawarded 300 points for winning a game in less than 5 turns (i.e.,inclusive, or less than or equal to 5).
The programs need to include the transformInputToIndex(String)and calculateWinner(int [][]) methods. Plus a new method calledcalculateBonus(int [][]) method that calculates the points awardedto each player depending on the number of turns they made to win.This method will return an int with the points. Also, theprintResults(int) methods, needs to be updated toprintResults(int, int), where the paramteres are the winner of thegame, and the points awarded.
Input
You will receive (from the user) the following as input (inorder):
Processing
Examples
Input
Output
P1 A1P2 B2P1 A2P2 B1P1 A3P2 Finish
1 2 0
1 2 0
1 0 0
Game Over - Player 1 Wins
300 points
P1 B2P2 A1P1 B1P2 A2P1 C1P2 A3P1 Finish
2 1 1
2 1 0
2 0 0
Game Over - Player 2 Wins
200 points
P1 C3P2 A2P1 Finish
0 0 0
2 0 0
0 0 1
Game Over - Draw
P1 B2P2 C2P1 A1P2 C3P1 C1P2 A3P1 B1P2 A2P1 B3P2 Finish
1 1 1
2 1 2
2 1 2
Game Over - Player 1 Wins
100 points
Use Scanner class
Java, please