CS156

CS156: Intro to C, Part I                

Fall 2017                

HW 3                

CS156 HW3: Functions in Oz!                

Description                

IndexYearTitle
11900The Wonderful Wizard of Oz
21904The Marvelous Land of Oz
31907Ozma of Oz
41908Dorothy and the Wizard in Oz
51909The Road to Oz
61910The Emerald City of Oz
71913The Patchwork Girl of Oz
81914Tik-Tok of Oz
91915The Scarecrow of Oz
101916Rinkitink in Oz
111917The Lost Princess of Oz
121918The Tin Woodman of Oz
131919The Magic of Oz
141920Glinda of Oz

Starting in the year 1900, L. Frank Baum wrote fourteen books about the Land of Oz. The first book was adapted into the popular 1939 movie with Judy Garland.                 

For this assignment, you will write a program called wiz.c that performs several tasks concerning these books. The program will prompt the user for what to do. The user can select one of the following:                 

Sample Run                

These values are those the user types in while running the program. “%” is the prompt and not a part of your program. Your output should match exactly.                 

    % c11 -Wall wiz.c
    % ./a.out
    Ignore the man behind that curtain!
    Request: z
    Invalid request 'z'; 'h' for help.
    Request: h
    h - help
    i - show age of the Oz book for that index
    q - quit
    y - show the Oz book for that year
    Request: i
    What index? 3
    Published 110 years ago.
    Request: i
    What index? 42
    Sorry, no such book.
    Request: y
    What year? 1920
    In 1920: Glinda of Oz
    Request: y
    What year? 1907
    In 1907: Ozma of Oz
    Request: y
    What year? 2017
    Sorry, no such book.
    Request: q
    % 

Requirements                

Required Functions                

You must define and use the following functions:                 

void show_menu();
Print the help menu, as shown above.
void show_title_given_year(int year);
Print the title for that year. Hint: Use a switch statement.
void show_age_given_index(int index);
Print the age of the book for that index. Hint: Use an array.

Note that the these functions should not call scanf. Instead, the last two functions should use whatever number was given to them. Presumably, scanf was called earlier to read the number.                 

How to submit your homework:                

Use                 

    ~cs156/bin/checkin HW3 wiz.c

or web checkin.                 

How to receive negative points:                

Turn in someone else’s work.                 

Modified: 2017-08-26T16:40                 

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