CS 135: Computer Science I
Spring 2008
Design, code, and test a C/C++ program to compute and display the
maximum bending moment,
, of a beam, which is supported on both
ends as shown in Figure 1.
The formula for maximum bending moment is:
The major difference from assignment two is that you have to ensure
that the inputs are valid. Handle cases when the user inputs
incorrect values for
, and
. When incorrect values are
entered the program should print an appropriate message to the
standard output and exit.
For this section of the assignment, please create and run at least five test cases and make sure that your program handles these situations. These test cases are the four cases below
Like in assignment 2, your program should print the maximum bending
moment for a weight that is half the distance as the the weight above
Your program must prototype, use, and define a
function to compute the maximum bending moment according to the
formula above. You need not worry about lining up output for this
part. Sample Testing (the executable's name is bender).
sushil@flash ~/classes/135/assignments/as4/code > ./bender Enter x (distance of w), w (weight), and l (beam length) 10 20 1 x = 10, w = 20, l = 1 Length l : 1 cannot be less than x: 10 Error in input, Exiting... sushil@flash ~/classes/135/assignments/as4/code > ./bender Enter x (distance of w), w (weight), and l (beam length) 10 20 10 x = 10, w = 20, l = 10 The maximum bending moment for distance 10 is: 0 The maximum bending moment for distance 5 is: 50 sushil@flash ~/classes/135/assignments/as4/code > ./bender Enter x (distance of w), w (weight), and l (beam length) 10 20 -100 x = 10, w = 20, l = -100 Length l: -100 cannot be negative Length l : -100 cannot be less than x: 10 Error in input, Exiting...
Design, code, and test a C/C++ program that computes scores for a
computer game, such as pong. Your program should generate the number
of blocks (blocks) and the number of misses (misses) using
a random number generator. Both blocks and misses are in
the range
through
. Your program should generate and compute
the score for two sets of blocks and misses.
We compute scores as follows:
Your program should write the number of blocks, misses, partialScore, bonus, and score to standard output. Your output should look like it does below. Sample Testing (the executable's name is pong).
sushil@flash ~/classes/135/assignments/as4/code > ./pong
Blocks Misses Partial Bonus Score
78 50 60340.00 100.00 60440.00
65 51 41740.00 100.00 41840.00
sushil@flash ~/classes/135/assignments/as4/code > ./pong
Blocks Misses Partial Bonus Score
52 64 26400.00 1000.00 27400.00
31 87 8740.00 1000.00 9740.00
sushil@flash ~/classes/135/assignments/as4/code > ./pong
Blocks Misses Partial Bonus Score
46 69 20470.00 1000.00 21470.00
72 49 51350.00 100.00 51450.00
This document was generated using the LaTeX2HTML translator Version 2002-2-1 (1.71)
Copyright © 1993, 1994, 1995, 1996,
Nikos Drakos,
Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999,
Ross Moore,
Mathematics Department, Macquarie University, Sydney.
The command line arguments were:
latex2html -split 1 as4S08
The translation was initiated by Sushil Louis on 2008-02-15