Computer Science 15-110, Spring 2010
Recitation for Week #1
- Logistics
-
Installation
- CA-Directed Lab
- triangleArea
- onesDigit
- eggCartons
- flagOfMali
- Student-Directed
(Collaborative) Lab
- hundredsDigit
- flagOfGhana
- More Flags (time permitting)
- Logistics
Introductions, Attendance, etc
- Installation
Everyone should run Hello World both on their laptops (if they have one)
and on the Linux machines in the lab.
- CA-Directed Lab
- triangleArea
Write a program that reads in 2 non-negative integers, the width and height
of a triangle, and prints the area of that triangle (using integer
division). You may assume the input values are non-negative.
Thought question: Why won't this work:
int
area = 1/2*width*height;
- onesDigit
Write a program that reads in a non-negative integer and prints just the 1's
digit of that number.
- eggCartons
Write a program that reads in a non-negative number of eggs, and prints the
number of egg cartons required to hold that many eggs (given that each egg
carton holds one dozen eggs, and you cannot buy fractional egg cartons).
Be sure your program works for multiples of 12, including 0.
- flagOfMali
Write a program that displays the flag of Mali. Your flag can use
built-in colors (rather than exactly color-matching with custom colors).
Your flag may not be fixed-sized, but rather it must entirely fill the
window, even when the window is resized, and it must not draw outside the
window! While the window's size may change, you may assume the window will
be roughly "flag-shaped" -- you will not be graded on how your flags appear
in, say, a tall thin window (which is not at all "flag-shaped").
Finally, you are not responsible this week for the "thin white line" problem
(which we will discuss in class next week).
Mali
(larger
image with details)
- Student-Directed
(Collaborative) Lab
- hundredsDigit
Write a program that reads in a non-negative integer and prints just the
100's digit of that number. If the number is less than 100, its 100's
digit is 0.
- flagOfGhana
Following the guidelines above, write a program that displays the flag of
Ghana. Replace the star with a circle.
Ghana
(larger
image with details)
- More Flags (time permitting)
As time permits, draw more flags (replacing stars with circles) from the
CIA Flags of the World page.
carpe diem -
carpe diem - carpe diem - carpe diem
- carpe diem - carpe diem -
carpe diem - carpe diem - carpe
diem