Previous
[ ../lab03/ ]
Next
[ ../lab05/ ]
Login. You need to create a "lab04" directory under your "cs201"
directory.
Perform all the exercises in this lab under this directory.
Download, compile, and test
[ ifelses.cpp ]
which is like an example you saw in class 05. Try several values. What
does it do with multiples of 7?
Change the program so that it correctly
describes any number from 2 thru to 49.
Section 3.6 (pages 121-123) presents a problem (when will my investment be worth
twice what it is now) and its solution. Here
[ doublinv.cpp ]
is the code. Download and run this.
The problem is that these days the interest rate is not 5% but 1%. Change the program
to find out how long it takes to double the investment today.
Download
[ george.cpp ]
and compile and run it. Confirm that it outputs a simple truth table.
Look at the tricks in the code -- how to use tab characters, how to do bool
for loops, how to output Booleans.
This program tests a special case of De Morgan's law (advanced Topic 3.3). Can you change it
to test another case?
This
[ george3.cpp ]
is a partial solution to Exercise R3.11 on page 147 of
Horstmann and Budd.
What column is missing? Can you change the program to output
the missing column?
Either show the lab instructor the programs
or print them and hand the printouts in.