THINK FIRST·CODE LATER

← All labs

Planning-poker round

Problem

Simulate one round of planning poker. The deck is 1 2 3 5 8 13 21.

Input: lines name vote until the end of input (each vote is a value from the deck).

Output:

  • If any vote is not in the deck: print Invalid vote from NAME: V for each such vote (in input order) and stop.
  • Otherwise print Votes: v1 v2 ... (in input order) and then:
    • if the highest and lowest votes are the same card or neighbouring cards in the deck (e.g. 5 and 8): Consensus: X, where X is the most frequent vote (on a tie, the higher value);
    • otherwise: Discuss: lowest L (names), highest H (names), names in input order separated by , .

Input:

Mei 5
Omar 8
Daniel 5
Aisha 5

Output:

Votes: 5 8 5 5
Consensus: 5

Data for this lab

Your program reads its data from standard input. Download the file, then give it to your program as shown below. Start with data set 1: its expected output is given.

s5-1-data-1.txt

Mei 5
Omar 8
Daniel 5
Aisha 5
What your program must print for s5-1-data-1.txt
Votes: 5 8 5 5
Consensus: 5

Run your program first, then open this and compare line by line: your output must contain these lines exactly.

How to give the file to my program

Terminal (macOS, Linux, or Windows Command Prompt), after compiling:

java Main < s5-1-data-1.txt

Windows PowerShell does not understand <:

Get-Content s5-1-data-1.txt | java Main

IntelliJ IDEA: Run → Edit Configurations → Redirect input from. Or simply paste the content of the file into the console when the program waits for input.

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.