Docsity

Homework Assignment 2 for CPS 196: Software Development Process and C Programming, Assignments of Computer Science

Toggle sidebar
bg1
CPS 196
Homework Assignment 2 Due Monday, October 8, 2007, at midnight.
While you may discuss this assignment with others, all work you submit must be your
own. That means, after discussing it, you must go back and write it up yourself.
Here are the steps of the Software Development Process that we used in Homework 1:
Software Development Process:
Part I:
1. Specify the problem requirements:
Restate the problem.
If any additional information is needed, get it and list it here.
If assumptions are made, list them.
2. Analyze the problem:
List the inputs, determine their data types and pick variable names for them.
List the outputs, determine their data types and pick variable names for them.
Give an example of the complete dialog with input and output values.
Give any formulas needed.
Work out one example in detail. Show the step by step calculations. If you need
any additional variables, identify their type and name them.
3. Design the algorithm to solve the problem by listing the steps. These simple
algorithms in class so far have the same basic steps:
Obtain the data.
Do the calculations.
Give the output.
Part II:
4. Write a C program, using the analysis above for comments:
a) The program should be well documented and have good variable names.
b) Turn the inputs and outputs of part 2 and the additional variables identified
in part 3, into declarations.
c) Take the steps from your algorithm in part 3, put them into your program
as comments, then fill out the C code below each comment.
d) Test your program thoroughly using the test values from part 3 and check
your results.
Follow the above steps to write C programs for two problems:
Program 1: Sixes and Sevens: Write a program that tests every integer between 1 and
100, and if the number divides evenly by 6 or by 7, print it out with a message.
pf2

Partial preview of the text

Download Homework Assignment 2 for CPS 196: Software Development Process and C Programming and more Assignments Computer Science in PDF only on Docsity!

CPS 196

Homework Assignment 2 Due Monday, October 8, 2007, at midnight.

While you may discuss this assignment with others, all work you submit must be your own. That means, after discussing it, you must go back and write it up yourself.

Here are the steps of the Software Development Process that we used in Homework 1:

Software Development Process:

Part I:

  1. Specify the problem requirements: Restate the problem. If any additional information is needed, get it and list it here. If assumptions are made, list them.
  2. Analyze the problem: List the inputs, determine their data types and pick variable names for them. List the outputs, determine their data types and pick variable names for them. Give an example of the complete dialog with input and output values. Give any formulas needed. Work out one example in detail. Show the step by step calculations. If you need any additional variables, identify their type and name them.
  3. Design the algorithm to solve the problem by listing the steps. These simple algorithms in class so far have the same basic steps: Obtain the data. Do the calculations. Give the output.

Part II:

  1. Write a C program, using the analysis above for comments: a) The program should be well documented and have good variable names. b) Turn the inputs and outputs of part 2 and the additional variables identified in part 3, into declarations. c) Take the steps from your algorithm in part 3, put them into your program as comments, then fill out the C code below each comment. d) Test your program thoroughly using the test values from part 3 and check your results.

Follow the above steps to write C programs for two problems:

Program 1: Sixes and Sevens: Write a program that tests every integer between 1 and 100, and if the number divides evenly by 6 or by 7, print it out with a message.

Program 2: 99 Bottles: As a way to pass the time on long bus trips, young people growing up in the United States have been know to sing the following rather repetitive song: 99 bottles of beer on the wall, 99 bottles of beer, You take one down and pass it around, 98 bottles of beer on the wall.

98 bottles of beer on the wall …

Write a C program to generate the lyrics to this song. Ask the user for input for how many verses to print. Since hardly anyone ever actually finishes the song, it is not clear what the last verse is, but it should be different from the others. Perhaps it ends: 1 bottle of beer on the wall, 1 bottle of beer, You take it down and pass it aroung, Now there are no more bottles of beer on the wall.

In testing your program to produce output to hand in, please use a small number of verses

  • small enough to fit on one page.

What to hand in:

Each program must have: a) One txt, rtf or word document with all of Part I of the development process. b) The .c file with the C program (do not hand in the project or solution files). c) One text file, with sample runs that you copied and pasted from the Console window. These should include the test runs described in part 3.

Submit these as three separate files to the Assignment 2 page in Blackboard.