Comp 101 March Madness - Part 0

March Madness Overview and Part 0

March Madness is right around the corner. This problem set provides the opportunity to bring look at historical team stats from the 2018 season and generate your own March Madness bracket based off of the data! The problem set consists of two parts

UNC Stats App - Part 0 (50 pts): You will write a program that finds the UNC players with the most and least points per game and the average points per game of the team.

Bracket Builder - Part 1 (50 pts): You will write a program that will advance teams based off conditions such as average free throw percentage.

Learning Objectives

After completing this problem set you should:

1. Be after to use for-loops to search through arrays

2. Understand how to access items in an array

3. Be more comfortable storing items in an array

Part 0. Starting the Dev Environment

As with in lecture, begin by opening up VSCode, ensuring your project is still open, and then running the following two commands in the VSCode Integrated Terminal:

  1. npm run pull
  2. npm start

The first command "pulls" the latest files needed for COMP101 into your repo, if any. The second command starts the development environment and will open your web browser to the local server. 

You should now see a folder called ps05-march-madness. Inside it there are two data files called part0-data.ts and part1-data.tsThey both contain arrays of basketball data that you will be importing into your programs. 

Part 1. Setting up an App

In the same directory used in lecture:

  1. Right click on the ps05-march-madness folder
  2. Select "New File"
  3. Name the new file: 00-unc-stats-app.ts
    1. Note: capitalization and punctuation are important!

Part 2. Starting your Code

2.0 Honor Code Header

All problem sets begin with an Honor Code pledge. Notice this header is contained within block comment tags discussed in Lecture 1. You can copy paste the pledge below and fill in your name and ONYEN.

/**
 * Author:
 *
 * ONYEN:
 *
 * UNC Honor Pledge: I certify that no unauthorized assistance has been received
 * or given in the completion of this work. I certify that I understand and
 * could now rewrite on my own, without assistance from course staff,
 * the problem set code I am submitting.
 */

2.1 Imports

The next step after ensuring the honor code header is to import the functions we'll use from the introcs library and the arrays from our data file. The first lines of code to add to your app is the following:

import { print } from "introcs";
import { uncPlayers, uncPlayerPointsPerGame } from "./part0-data";

2.2 The main Function

Your program's execution will begin in a special function named `main`. Inside this function, you will put all of your code. It will run once main is called (main();).

export let main = async () => {   
// TODO: Put all of your code here
};
main();

Part 3: UNC Stats App

In this part of the problem set, you will use for-loops to find the UNC players with the most and least points per game and the average points per game of the team. To do this, you will need to use the two arrays you imported from part0-data.ts. The first array uncPlayers contains the names of all the UNC basketball players from the 2018 season. Each index of the uncPlayerPointsPerGame contains the points per game of the player in the uncPlayers at that same index. For example, Cameron Johnson, who is at index 2 of uncPlayers (remember arrays are 0 indexed) scored an average of 12.4 points per game. 

Part 3.1: Find the player with the most points per game 

Write a for loop to find the player who scored the most points per game this season. After the loop, in one print statement, print this player's name and the points per game he scored. 

Also note, when the autograder is posted it will test using a different data set than this season's to ensure your computations work more generally. 

Part 3.2: Find the player with the least points per game 

Similar to part 3.1, write a for loop to find the player who scored the least points per game this season. After the loop, in one print statement, print this player's name and the points per game he scored. 

Part 3.3: Find the average player points per game for UNC

Find the average player points per game of the season by using a for loop to sum all the values in the uncPlayerPointsPerGame array then compute the average of these numbers. Print this average in a print statement after the loop.

Tadah! That's it for Part 0!

Part 3.4: Publish your app.

With your program running in your web browser, find the green "Publish App" button. If you are not still logged into introcs.com, you will be prompted to log in, and then your app will be bundled and published to the web!

Part 3.5: Submit for grading

Once the grader is available, to submit for grading, first publish your project as per Part 3.4. Then, go to My101 in the top-right right corner of this page and select "Submit" next to the assignment. From here you should see a button that allows you to submit for grading. Your work will be graded through an automated process. If you receive points off, please select the "Report" link to see which tests did not pass. You can resubmit as many times as you'd like without penalty up until the deadline. We want you to keep working toward full credit on problem sets!

Now you are ready to make a bracket in Part 1!