Projects for CMPSC 201C , Fall 2007
- Project 3 : Factorial , Due Wed. Oct. 1, 2008, 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 will 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 safe-guard 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 for-loop in your program.
The name of the file containing your source code
must be factorial.cpp and should be submitted
to your account on mac6.ma.psu.edu using sftp
- Project 2 : Speed of Car,
Due Fri. Sept 19, 2007
- Write a program which computes the average speed of a car. Floating point numbers are required. The program
should solicit from the user :
- The distance travelled
- The time needed
It also should 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
- Print a nice good bye message
When done provide me with a copy of your source code by copying
your file to your account on "mac6.ma.psu.edu" using sftp.
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
Math skills : Algebra
- Project 1 : Program hello.cpp,
Due Tue. Sept 9, 2008
- Modify the program hello.cpp we wrote in class :
- to contain the required lines of comments at the top of
your cpp-file as noted below under
the header "The following points pertain .....".
- investigate the influence of leaving out the \n part
inside the apostrophies of the cout-statement.
- add a line to force the program to print out a 2nd line
describing the result of leaving out the \n.
- add another cout-statement to your program describing the kind of
error message you get from leaving out a semicolon at the
and of a code line.
- submit your code to Angel, I will re-compile and run it on
my computer.
words
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 user-defined 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 re-compile your program and run test cases with
it on my computer including checking the numerical results it produces.
- Once done and checked, please save your file containing your source code
to the appropriate Angle Drop Box.
Without that I will not be able to grade your work.
Zig Herzog; hgn@psu.edu
Last revised: 09/23/08