Wednesday, February 24, 2010

Lab 6

You can put all this (except 7) into a single C++ program.
1) Take in two numbers. Determine the minimum, maximum, and average of these numbers and print them out.

2) Print out your name 100 times, one on each line.

3) Print out the numbers 1 to 100.

4) Print out the even numbers in the range of 2 to 100.

5) Print out the odd numbers in the range of 1 to 99.

6) Loop forever, asking the user for the grades of midterm and final, and print out, each time, the average of these two values.

7) For your own sakes, step through the code in this example:
"Enter even: use while to force correct input 02-22-10"

8) Research the do-while loop. Using a do-while loop, repeatedly ask the user for a password. If it is "swordfish", proceed. Otherwise, loop around again.

Monday, February 22, 2010

Quiz 1

1) If I want to print something out to the screen, I would use:
a) CIN
b) COUT
c) cin
d) cout
e) more than one of the above

2) At the top of all the programs so far, we have #included
a) iostream
b) istream
c) ostream
d) streamstream

3) If I wanted to store a value such as "hello", I would put it in a variable of type:
a) int
b) string
c) double
d) cout

4) The arrows for cin go in the direction of:
a) >>
b) <<
c) ^^
d) vv

5) Write a program that will print out a double, 0.3333, by first dividing 1 by 3. Take care that you don't end up printing just a 0, because of the rules of integer division.

lab 5

Lab exercises

1) Using if statements in the program, ask someone for his or her first and last name. If the total number of letters in both names is more than 20, tell them that their name is too long and that they must shorten it.

Google "C++ string length"

2) Look up the ?: operator, and modify one of Dr. Ryba's if programs to use this operator instead.

3) Using ifs, take in a number and find out if it is a leap year. The rules for
leap year are as follows:
every 4th year is a leap year
unless it is a century
unless it is a 4th century, in which case it is a leap year

Thursday, February 18, 2010

Lab 4

1) Convert celsius to Fahrenheit. (the opposite of what you did in class.)

2) Step through the coins program (using the F10). Set watches on all the variables.

3) http://en.wikipedia.org/wiki/Polish_coins_and_banknotes
Take in a number of grosz, and show the minimum number of coins to give this amount in change.
http://en.wikipedia.org/wiki/Polish_coins_and_banknotes

4) Convert zloty to a bunch (5) of other currencies:
http://www.lse.co.uk/currency-converter.asp?Sym=PLN&Currency=polish_zloty


http://venus.cs.qc.edu/~ryba/cs111/

Wednesday, February 17, 2010

HW # 2

A program which takes in the cost of an item, the tax rate, and tells you the total.

Monday, February 8, 2010

Lab 3

1) Run through all the programs up to the end of 2-8-10 on Dr. Ryba's website.

2) Work through all the tutorials up to Tutorial 2 on this website.

3) In Visual Studio, step through this program.

HW:
1) A program which gets in the speed (in mph) and time elapsed (in hours), and calculates and prints out the distance traveled.

Wednesday, February 3, 2010

Lab 2 summary

plan:
qccs111.blogspot.com
1) pico our first program on *venus* compile it, execute it.

pine = pine is not elm
pico = pine composer
ls = directory listing
pwd = present working directory

2) Get persons name and greet them.

#include
#include
using namespace std;
int main()
{
cout << "Please enter your name: ";
string theName;
cin >> theName;
cout << "Howdy, " << theName << "!" << endl;
return 0;
}

HW: Modify this to ask for first and last names, and greet the person using the full name.

Welcome to the Spring 2010 semester

That is all for now.