CS157

CS157: Intro to C, Part II                

Fall 2017                

HW 2                

CS157 HW2: Baseball!                

For this assignment, you will write a program called bb.c, which will help you manage your baseball team.                 

You don’t have to keep track of much: each player has a name, a player number, and a batting average.                 

Data Structures                

You must store the team as an array of structures. The array must not be a global variable.                 

Sample Run                

Here is a sample run. Your output must match exactly. User input looks like this.                 

    % ./a.out
    Please rise for our national anthem.

    a name number average (add a player)
    h (help)
    q (quit)
    p (print all players)
    p number (print a single player)

    Command: p
    Player   Num Average
    ======== === =======

    Command: a Jack 12 42

    Command: a Theresa 40 300

    Command: a Babe 3 342

    Command: p
    Player   Num Average
    ======== === =======
    Jack     12  .042
    Theresa  40  .300
    Babe     3   .342

    Command: p 40
    Player   Num Average
    ======== === =======
    Theresa  40  .300

    Command: p 99
    Player   Num Average
    ======== === =======

    Command: a Lou 3 125
    The team already has a player #3.

    Command: p
    Player   Num Average
    ======== === =======
    Jack     12  .042
    Theresa  40  .300
    Babe     3   .342

    Command: z
    Bad command 'z'.
    a name number average (add a player)
    h (help)
    q (quit)
    p (print all players)
    p number (print a single player)

    Command: h
    a name number average (add a player)
    h (help)
    q (quit)
    p (print all players)
    p number (print a single player)

    Command: q

Requirements                

Notes                

You will lose points if your program:

How to submit your homework:                

Use                 

    ~cs157/bin/checkin HW2 bb.c

or web checkin                 

How to receive negative points:                

Turn in someone else’s work.                 

Modified: 2017-08-26T16:41                 

User: Guest                 

Check: HTML CSS
Edit History Source
Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2015 Colorado State University
CS Building