Lesson 6.9 · Write it
Club members
A whole programPython or Java10 tests, 8 of them hidden
On a phone? Put the lines in order instead
Sign-ups for school clubs are saved in signups.csv. Write a program that reads the name of a club typed in, then prints everyone who signed up for it.
- The first line of the file is a header,
name,club. It is not a sign-up. - Every other line is one sign-up: a student's name, a comma, then the club, such as
Ana,Chess. - Print the name of each student whose club is exactly the club typed in, capitals included, in the order they appear in the file.
- Then print
Members:followed by how many there were. With none, that isMembers: 0. - Names and clubs have no commas, and never start or end with a space. The file may have only its header. The last line may or may not end with a line end.
Your program is run several times, each time in a folder that holds only the files shown for that run.
Running Java here comes later. You can put this answer's lines in order instead. You can still write your Java answer (it stays while this page is open) and compare it with our worked solution. Or try this exercise in Python.
Examples
Your program is run 10 times: the 2 examples below, and 8 hidden ones that check the rules above. Only what it prints is checked. Each run starts in an empty folder that holds only the files shown for it.
two of the three sign-ups are for Chess (rules 2 to 4)
You type
- typed: Chess
It prints
Ana Cy Members: 2
Files in its folder
signups.csv name,club Ana,Chess Bo,Drama Cy,Chess
one sign-up for Drama (rules 3 and 4)
You type
- typed: Drama
It prints
Bo Members: 1
Files in its folder
signups.csv name,club Ana,Chess Bo,Drama Cy,Chess