GU Computer Engineering Department created a new mathematical game that can be played with two people. In this game, you are given a list of random integers. At each round, the first player takes two numbers from the list and calculates the sum of these numbers. Then, the second player takes two numbers and makes the same calculation. The higher one is going to take the round and increment the score by 1. At the end of the game, who has the better score will win the game. Here are the rules for the game: There are always an even number of items on the list There are two colors for the players: Green and Red Green starts the game At each round, green plays and then red plays The player takes the first and the last numbers The game can end Tie when the scores are the same. The game will end when there is no element to take from the list Your program on java will simulate the rounds and find out the winner, Green or Red or Tie. The input will be two lines. Input Format The first line gives the number of items, n, and the next line includes n integers representing the list. Constraints The given n is always an even number Output Format The output will be a single line showing the winner color, Red or Green or Tie, and the winner's score. Sample Input 0 81 4 9 7 3 6 8 8 Sample Output 0 Tie 1 Explanation 0 Round 1: Red wins (Green: 1+8, Red: 4+8) Round 2: Green wins (Green: 9+6, Red: 7+3) Red : 1 & Green: 1 -> Tie

EBK JAVA PROGRAMMING
8th Edition
ISBN:9781305480537
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question

AGU Computer Engineering Department created a new mathematical game that can be played with two people. In this game, you are given a list of random integers. At each round, the first player takes two numbers from the list and calculates the sum of these numbers. Then, the second player takes two numbers and makes the same calculation. The higher one is going to take the round and increment the score by 1. At the end of the game, who has the better score will win the game.

Here are the rules for the game:

  1. There are always an even number of items on the list

  2. There are two colors for the players: Green and Red

  3. Green starts the game

  4. At each round, green plays and then red plays

  5. The player takes the first and the last numbers

  6. The game can end Tie when the scores are the same.

  7. The game will end when there is no element to take from the list

Your program on java will simulate the rounds and find out the winner, Green or Red or Tie. The input will be two lines.

Input Format

The first line gives the number of items, n, and the next line includes n integers representing the list.

Constraints

The given n is always an even number

Output Format

The output will be a single line showing the winner color, Red or Green or Tie, and the winner's score.

Sample Input 0

81 4 9 7 3 6 8 8

Sample Output 0

Tie 1

Explanation 0

Round 1: Red wins (Green: 1+8, Red: 4+8) Round 2: Green wins (Green: 9+6, Red: 7+3) Red : 1 & Green: 1 -> Tie

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT