CS 157 Spring 2001                          Assignment 7 – Using a Function                                    100 points

 

Assigned: 03/07/2001

Due: 03/21/2001 at the start of class

 

Pre-Lab (Do Before Lab):  Bring an empty (or nearly empty) disk (keep any .c files you create, but other files can be deleted). Plan out sequence of statements needed for program.

 

Main Assignment:

Write a program that can play bing bang buzz perfectly for games that last up til and including a user specified number. The program must output "bing"  if a number is evenly divisible by 3, "bang" if a number is evenly divisible  by 5, and "buzz" if a number is evenly divisible by 7. The program should output all that apply for a given number (e.g. 15 gets both "bing" and "bang"). The program should use a function called dividesEven  which I will provide, it does the following: given an integer number and divisor, returns 1 if the number is evenly divisible by the divisor, and 0 otherwise (substitutes for true and false). The main  program should use this function for each number being considered, for each of bing, bang, and buzz (only one such function is needed!). The main program should loop from 1 to the quitting number, and print each number on a separate line - with any appropriate sound words next to the number. In addition, the program should figure out and report how many numbers got no sounds (this may take some thought!)

 

Sample interaction with the user:

Welcome to the Bing Bang and Buzz Program

 

How many numbers to process right now? 16

 

    1

    2

    3 bing

    4

    5 bang

    6 bing

    7 buzz

    8

    9 bing

   10 bang

   11

   12 bing

   13

   14 buzz

   15 bing bang

   16

 

 7 numbers had no sounds

 

Hand-in:

     1) Listing of the program

     2) Disk with  .c source file plus .exe executable file.

 

NAME YOUR PROGRAM FILE yourlastname7.c

 

Miscellaneous:

                1. It is intended that you use my function.  Do it. You will need to get the files divides.h and divides.c from my WWW page and put them on your disk. Use an include:  #include “divides.h”   NOTE that this is different than #include<stdio.h>. Also, when you create the project, you will need to “add to project” my two files in addition to your file.

2. Make the output of your program like mine

3. MAKE SURE YOUR PROGRAM WORKS! (i.e. more than just removing compile errors). You can test your program on the above example, but make sure you test it on other data as well - I will!

4. Remember: Indentation, meaningful variable names, and meaningful comments. Weaknesses in any of these could result in points off. You MUST include comments that explain your program in order to get full credit. Also, make sure you put YOUR NAME and e-mail address in comments at the beginning of the program.