Skip to content

alstondsouza1/response-tally

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

response-tally

An exercise for counting responses to a survey.

Getting Started

Fork and clone this repository. You can look at the instructions from our previous exercise as a reminder of how to do this. MAKE SURE TO CLONE YOUR FORK, NOT THE ORIGINAL.

Data Format

There is a file responses.txt that contains the data we'll be working with. Here's what's inside it.

studentA maps
studentB maps
studentA lists
studentB arrays
studentC loops
studentC arrays
studentA compound

The first string on each line is a pseudonymous id of a student. The second string is a topic they want to know more about.

Template Code

Look at Tallyer.java to see the already provided code. Take a look over it and predict what it will do when you run it.

Running the code

  1. Open your terminal in VS Code. On Mac/Linux, it should have the right type of terminal by default. On Windows, follow these instructions to make Git Bash the default terminal. (You do not need to do step 1 because you already have installed git).
  2. Verify you are in the response-tally directory by running pwd (print working directory) on the terminal. The printed directory should end in response-tally.
  3. Compile the Java files by running javac src/Tallyer.java
  4. Run the main method of Tallyer by running java -cp src Tallyer < responses.txt

Submitting

Once you have completed the below section (Modifying the Code), please open a Pull Request (PR). Please copy and paste your PR URL into Canvas to receive credit. Include your attempt at Wave 2, even if you did not complete it.

Modifying the code

Wave 1 (Required)

Implement tallyTopics. Read the Javadoc carefully to understand what the method is meant to do. Make sure to compile your code each time before running it!

For the sample file, a correct output would look similar to:

{maps=2, lists=1, loops=1, arrays=2, compound=1}

The order is unimportant.

As an extra test, try downloading your class' data from Canvas and checking that your program properly handles it.

Wave 2 (Please attempt, but it is ok if you do not finish)

Implement tallyTopicsFiltered. Read the Javadoc carefully to understand what the method is meant to do. Make sure to compile your code each time before running it!

For the above sample file, a correct output would look similar to:

{maps=1, loops=1, arrays=2}

The order is unimportant.

Extra Challenges (Entirely optional)

Some more ways to exercise:

  1. Display the results in sorted order
  2. Refactor the code so that it is object oriented
  3. Robustly handle malformed files
  4. Come up with some other interesting way to work with the data!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%