Class Topics/Activities Homework
1
2
  • Submit Assignment #1
  • Quiz on the hello world program .
  • Any questions regarding Angel or obtaining & installing the Visual C++ compiler ?
  • Any questions on using the Visual C++ compiler?
  • a program that uses the incrementing operator, a compound operator, a counter statement, the pow and sqrt functions, and the mod operator
  • a program that illustrates garbage values, overflow, underflow, integer division, typecasting & constants
  • comment out sections of code using // as well as /* ... */
  • a program that uses an int variable and prints the value of the variable
  • a program that stores a floating-point value in an int variable and prints the value of the variable
  • a program that performs a computation and an assignment with doubles and ints and then prints the new value of the variable
  • a program that prompts the user to input an integer value and then obtains that integer value from the user via the keyboard
  • trace a program on scratch paper to check the logic of the program
  • compiling and testing a program incrementally
  • a program that reflects the Coding Standards for this course
  • a program that does not reflect the proper Coding Standards for this course
  • Discuss the numerical ranges for int and double data types. Possibly review the use of INT_MAX, INT_MIN from limits.h and DBL_MAX and DBL_MIN from float.h.
  • Practice identifying declaration, assignment & comment statements
  • Discuss Assignment #2 & the Five Steps of the Programming Process.
  • Discuss test plans & pseudocode. Also, discuss the use of constants.
  • Demonstrate how any demo program in this web site can be reviewed and executed using copy and paste.
3
  • a program that reads data from a file
  • a program that writes data to a file
  • a program that reads data from one file and writes data to another file
  • a program that reads data from a file, closes it, & then writes to the file
  • a program that searches a file for a specific piece of information
  • a program that appends data to the end of a file
  • a program that inserts data into the middle of a file

  • declaring and initializing string variables; you must #include <string>
  • when to use char and when to use string
  • how to display a specific letter within a string variable (using brackets)
  • using the length function with string variables
  • a program that uses setprecision to truncate a value to the nearest tenths place
  • a program that rounds a floating-point value to the nearest tenth's place using my "macho" method of rounding
4
  • use an if statement
  • use an if/else statement
  • use an if/elseif/elseif statement
  • use an if/elseif/elseif/else statement
  • use various logical operators such as !, &&, and ||
  • use various relational operators including <, >, <=, >=, ==, !=
  • use nested if statement and compare it to an if statement with an And (&&) compound expression
  • compare two separate if statements to an if statement with an Or (||) compound expression
  • use an if/else if/else if to organize a menu
5
  • use a for loop
  • use a while loop
  • use a do while loop
  • using flag variables in control expressions of indeterminate loops
  • using sentinel values and loops when receiving input
  • use a loop to perform a sequential search to find the greatest value entered into a program
  • use a loop to obtain a running total and then compute the average
  • uses continue statements within a loop to validate user input
  • uses a break statement to immediately terminate a loop
  • using logical and relational operators in the control expressions of indeterminate loops
  • observe the proper use of curly braces and blank lines for good style and readability
  • Practice deskchecking loops including nested ones.
6
  • use a function to round a value to the nearest whole number
  • modify the function to round a value to any decimal position (Hint: use the pow library function.)
  • use a function to compute sales tax as a classwork exercise
  • use a function to calculate a number to a power
  • use a function that generates a random number
  • use a void function that displays your name in a class demo program
  • use a void function that displays two parameters as a fraction (e.g. "2/3") unless they form a proper fraction in which case the simplified integer value should be displayed (e.g. "3" instead of "9/1").
  • use function prototypes
  • (optional) save a function in another file and "include it" in a source file
7

Exam #1

  • Read the online Arrays notes
8
  • storing input (cin) such as exam scores into a one-dimensional array using an indeterminant loop (use sentinel values or flag variables)
  • same as above only reading data from a file & using (eof)
  • calculate and display the average of the inputed exam scores
  • a program that performs a linear search for the greatest value in an array
  • a program that performs a binary search for a specific number within a sorted array
  • reads data from an external file into a 2 x 3 matrix
  • displaying a matrix neatly
  • obtaining the sum of all of the elements of a 2 x 3 matrix
  • obtaining the row sums of a 2 x 3 matrix
  • obtaining the column sums of a 2 x 3 matrix
  • finding the maximum value in a 2 x 3 matrix
  • adding two 2 x 3 matrices
  • a program that multiplies a 2 x 3 matrix with a scalar value
  • Write a function named findMax that accepts an array of integers and returns the maximum value
9
  • Play the "guess a number between 1 and 100 game" & review the Bisection Method Guessing Game demo

  • Finding roots with the Bisection Method

    • Discuss the tolerance and how we can compute the exact number of iterations to reach a desired answer (p. 756).
    • Review the Bisection Demo program (aka Program 14.1)
      • Execute the program with different sets of inputs.
      • Change the function f and execute again. Use a function from Exercise 14.2 #1a or other functions with easy-to-compute roots.
      • How does the convergence criteria (epsilon) relate to the tolerance (delta)?
      • Why does the program include the     if (curwidth < epsilon)     statement?
      • Why does the program care about the maximum number of iterations & use imax as an upper bound for the for loop?
      • Notice the use of a     return;      statement with no value being returned by the void function.
  • Re-read the online Finding Roots notes
  • Trace Bisection Demo program with a = 2, b = 10, epsilon = 0.1, and imax = 100 and the f(x) = (x - 2) * (x - 2) - 2
10
  • Finding roots with the Method of False Position (aka Regula Falsi)

    • Discuss the similar triangles ABC & CDE on p. 762 and derive the x2, new guess for the root
      • Note that this interpolation is a line segment in Figure 14.3 on p. 762 and that the point of intersection between the line segment and the x-axis becomes the new x3 right boundary for the next iteration as depicted in Figure 14.4 on p. 763.
      • We cannot predict the exact number of iterations to achieve desirable results based on tolerance as we can with the Bisection Method so having the user specify a max number of iterations is necessary.

    • Modified Method of False Position (aka Modified Regula Falsi Method)
    • Notice how "cheating" your interpolation line segment towards the side of the interval with the root narrows you in more quickly.
    • Note how the root alternates on each side of the interval on each iteration. If the function does not change sign (f1 * f3 > 0) then the original interval doesn't contain a root.
    • Discuss the use of the relaxation factor.
    • Review the Modified Regula Falsi Demo program (aka Program 14.2)
      • Execute the program with different sets of inputs.
      • Change the function f and execute again. Use a function from Exercise 14.3 #2 or other functions with easy-to-compute roots.
      • Note the substitution of the "similar triangle" next guess computation assignment statement for Program 14.1's midpoint assignment statement.
      • Why does this program care about the maximum number of iterations (imax) and use imax as an upper bound for the for loop?
      • Note the use of the constant RELAX.
  • Study for exam
  • Read pp. 751-770
  • Do Exercise 14.1 #1 on p. 755
  • Do Exercise 14.2 #1a on p. 760
  • Do Exercises 14.3 #3b & #4b on p. 769
11

Exam #2

  • Read the online Integration notes
  • Read pp. 774-783 if supplied by instructor

12
  • Integration Methods
    • single application Trapezoidal Rule
      • derive the formula
      • discuss the error
    • multiple application Trapezoidal Rule
  • Do Exercise #1 a in Section 14.6 on p. 778
13
  • Integration Methods
    • Simpson's 1/3 Rule when number of segments (n) is even
    • Simpson's 3/8 Rule when n is odd
14
15
  • Solving systems of linear equations
    • Cramer's Rule
      • Computing determinants of 2 x 2 and 3 x 3 matrices by hand and/or with Excel's MDETERM function
      • Write C++ functions to find the determinant of a 2 x 2 matrices and 3 x 3 matrices.
      • Execute & review the Cramer's Rule Demo program
    • Do the following practice problems related to solving systems of equations:
      • translate sets of 3 equations with 3 variables into an augmented matrices and vice versa
      • use Gauss Elimination to solve a set of 3 equations with 3 variables
      • use Gauss-Jordan's Method to solve a set of 3 equations with 3 variables
      • find the determinants of 2 x 2 matrices
      • compute the determinants of 3 x 3 matrices
      • use Cramer's rule to solve a set of 3 equations with 3 variables
16
  • Final Exam