 Project 9 : Matrix manipulation, Due Monday,
Dec. 17, 11:59 pm
Write a program which reads the coefficients of a matrix consisting
of N rows and N+1 columns from a file on disk. This file has to have the
following format :
1. row : just the number N itself
2. row : the N+1 coefficients of the first row of the matrix
3. row : the N+1 coefficients of the 2nd row of the matrix
.
.
(N+1). row : the N+1 coefficients of the N'th row of the matrix.
The coefficients of the matrix are of data type "double".
The name of the input file is arbitrary but is at most 15 characters long.
Your program has to work for any number N between 2 and 20 and stop
with an error message if the file contains a number outside this range.
After reading in all the data using a 2D array your program is to do
the following :
Multiplying each coefficient of the 2nd row with the same value
and adding the results to the
corresponding coefficient of the first row and making the resulting
coefficients become the coefficients of the new second row replacing the old.
Choose the
multiplier such that the 1. coefficient in the new 2nd row becomes zero !!
Repeat this for the 3rd etc. up to and including the N'th row.
Once this accomplished we will expand this to all the elements
below the major diagonal and then maybe even attempt the backward
substitution step. See you Friday, Dec 14, in class.
The final answer, which your program prints to the screen, must be
a matrix consisting of N rows and N+1 columns with all elements
below the major diagonal zero.
The name of the file containing your source code
must be matrix.cpp
New C++ skills : multidimensional arrays
 Project 8 : 1D array , Due Fri. Dec. 7, 2012
(11:59 pm, no grace period)
Write a program which reads an arbitrary (≤21)
number of values ( data
type double) from a file on disk and stores these values in an
1dimensional array. Subsequently the program will order these values
(most positive first) and write the ordered values to a second file on disk.
Your program must ask the user for the names for the input and output
files. The length of the file names is restricted to 19 characters (no blanks).
Also, have your program print out the minimum, maximum, and average
of the numbers of the input file.
The name of the file containing your source code
must be order.cpp
New C++ skills : 1D arrays
`
 Project 7 : Numerical Integration, Due
Mon. Nov. 12
Write a program which numerically integrates a definite integral using
Simpson's rule. The mathematical
background for numerical integration
is described in Chapter 10.4 of the text containing a paragraph on Simpson's
rule and at
Mathematics for trapezoidal and Simpson's rule.
 Your program will request from the user the value of the upper and lower
integration limits.
 Your program will also request from the user the number of integration
intervals, n.
Note, a requirement for the Simpson rule to work is that the number of
intervals, n, is even. Your program must verify the user's input and reject it
if the user's input is an odd number (or alternatively increases the user's
input by 1 and informing the user of that).
 After the user has provided his/her input your program determines
an approximation to the value of the definite
integral for the number of integration intervals prescribed.
 In order to adapt your program quickly to find solutions for
a new integrand embed the equation for the integrand in a function
called "integrand".
 Use your program first on a function ( 5.1·sin(2.3 x) ) for which you
know the analytical solution for given integration limits
( 0.2 and 1.4 ). Let your program "solve" this case
at three different numbers
of intervals ( n = 10, 20, 40 ) and judge the results critically.
Theory predicts that the magnitude of the difference between the analytical
solution
and the values obtained by your program should be
approximately proportional to 1/n^{4}; for Simpson's rule. You will see
here that the differences are so small that the usual
output with 6 significant digits is not accurate enough. Force your
program to print out more digits, for more details on that click on
How to Format a programs Output.
 Document your results carefully in the preamble of your soure code.
 Now use your program to solve the integral
and document your results carefully in the preamble of your soure code.
The name of the file containing your source code
must be integral.cpp
 Project 6 : Root Finding , Due Mon. Oct. 29, 2012, 11:55pm
Create a program which finds the roots of the funtion :
f(x) = a*sin( b* x ) + c*cos( d*x )
using the bisection method.

The values for the constant "a","b","c", and "d" are to be provided by
the user on the keyboard and are of type double.
 The user must also specify the two boundaries of the starting interval
and the program must ask again for these if f(x) is not greater
than zero at one boundary and less than zero at the other boundary.
 The user must also be able to specify a termination criteria. For this
project the iteration should terminate when the size of the interval
containing the root falls below the value specified by the user.
 The program must contain a userdefined function which returns the
value of f(x) with arguments for a,b,c,d, and x.

The name of the file containing your source
code must be bisection.cpp
New C++ skills : Using library and userdefined functions
Math skills : Rootfinding by
bisection
and regular falsi method.
 Project 5 : sinefunction , Due Mon. Oct. 8, 2012, 11:55pm
Create a program which calculates the value of sin(x) for any value
of x between 0 and 2*π (inclusive). Your program must terminate in
cases of illegal input value : <0 , > 2*π , and accidental
illegal character and tell the user why exactly it terminated.
Use a while loop to allow for repeated user input.
sin(x) = x/1!  x^{3}/3! + x^{5}/5!  ....
The result must be accurate to within at least 6 decimal digits
behind the decimal point.
In addition to printing out the result your program must also print out
the number of terms included in your calculations.
Important : To insure efficiency of your program I will inspect your code in detail to verify that your program needs to perform
a single multiplication plus a single
division plus a single subtraction for each term in above series.
Note : see Value of
π
The name of the file containing your source code
must be sine.cpp.
 Project 4 : Factorial , Due Mon. Oct. 1, 2012, 11:55pm
Create a program which for an integer number n, to be provided
by the user, determines the value of n!( n factorial ). Design
the program such that after calculating n! and informing
the user of the result, it will ask the user for another value for
n until the user responds by entering a value of 0 (zero). At that time
the program must terminate with a nice message to the user.
Of course, you have to inform the user of that possibility of entering
zero. In addition to this you have to safeguard your program by
rejecting negative values for n.
ALSO, use a first version of this program to explore at what value
of n an overflow condition occurs and amend your program to
prevent that from happening (and of course telling the user about it).
MANDATORY : You must have a while and a forloop in your program.
The name of the file containing your source code
must be factorial.cpp.
New C++ skills : For and whileloop
Math skills : Algebra
 Project 3 : Speed of Car,
Due Fri. Sept 21, 11:59pm

Write a program which computes the average speed of a car and the
carbon foot print for the indicated travel. Floating point
numbers (data type "double") are required.
The program
must solicit from its user :
 The distance travelled.
 The time needed to travel above distance.
 The miles per gallon the user's car gets at 55 mph.
Your program must provide the following feedback based on the values
provided by the user :
 Reflect the input the user provided
 The average speed
 Print a warning if the speed was above 55 mph or a compliment
(for saving gas) if the average speed was below 55 mph
 Determine the amount of gas ( gallons ) the car used for the trip.
Here your program must take into account that the mileage
a car gets depends on its speed. Use the formula :
mpg = mpg55 * ( 55./ speed )^{2}
Here "speed" = actual velocity of car
"mpg55" = miles per gallon at 55 mph
"mpg" = miles per gallon at "speed"
 Calculate the numbers of pounds of CO_{2} the car
put into the air during this travel (According to the EPA
one (1) gallon of gasoline produces 19.4 pounds of CO_{2}
,
http://www.epa.gov/OMS/climate/420f05001.htm#calculating.
 Print a nice good bye message
The name of the file containing your source code
must be car.cpp
New C++ skills : Getting input from keyboard, outputting to monitor,
mathematical operators for floating point numbers.
Math skills : Algebra
 Project 2 : Program intParen.cpp,
Due Fri. Sep. 12, 11:59pm
 Write a program ( file name intParen.cpp ) which solicits from the
user four (4) integer numbers ( I use the variable names i, j, k, and m
to store the values the user provides ) and performs the following
actions :
 Verifies that the use of parenthesis in C++ is identical to
its use in mathematics by performing the following operations
which all should give the same answer.
 (i+j)*(k+m)
 i*k + i*m + j*k + j*m
 i*(k+m) + j*(k+m)
 (i+j)*k + (i+j)*m
Have your program print out the results for each of the four cases
and inform the user ( using cout ) that the four results should
be ( should not be ) identical.
 Have your program investigate whether the two statements
change "i" by the same amount. For each of these two statements
have your program print out the value of "i" before and
after the operation. Have the program inform (cout) the user
whether the two results should have identical outcome or not.
 Finally, add the following assignments in your
program :
 i = 7 ;
 j = 11;
 k = 3 ;
 m = 5;
and have your program calculate and print out the result
of the following operations :
 i/k
 i/m
 j/k
 j/m
Observe the results your program produces and add a
"cout" statement to your program which prints out your conclusions.
 Project 1 : Program hello.cpp,
Due Fri Sept. 7, 11:59pm
 Modify (get to work) the program hello.cpp we started in class :
 to contain the required lines of comments at the top of
your cppfile as noted below under
the header "The following points pertain .....".
 add an additional cout statement describing your observation
on the output of the program when you add a \n to the
character string of your first coutstatement and then
omit the "<< endl" in the first coutstatement.
 add another coutstatement to your program describing the kind of
error message you get from leaving out a semicolon at the
end of a statement.
The following points pertain to each and every project and should be
read carefully :

Each file containing source code of a project must have the
following informative block at the top of the file with the dots
replaced by the proper information :
:
// Created by : .....
// Access account ID : .....
// Date of Creation : .....
// Purpose of Program : ....
Usually, the Purpose section will contain more than 1 line.
 Each of your userdefined functions must contain a blurb at the top of its
definition outlining the purpose of the function and an explanation of the
formal arguments.
 Each variable you declare either in the main program or in a function
must be commented on concerning its purpose and possible
restrictions. This is usually done at the point where a variable
is declared.
 Clearly document in your program where the user input section,
the user data validation section and the computational section start and end.
 Be aware of that I will recompile your program and run test cases with
it on my computer including checking the numerical results it produces.
Last revised: 08/23/13