CS 2102 Homework Assignment #1
Assigned: Friday
October 27, 2006, 10:00
AM
Due: Tuesday October 31, 2006,
10:00 AM
Guidelines: Now
Available
Solutions: Now
Available
Description
This homework is a "starter" assignment and contains lots of independent
questions to test your knowledge. The questions draw upon
your readings, some of which are for next Monday's class.
- [20 pts.] Write a program that computes (a) the
volume of a cylinder with
radius 6 and height 3; (b) the
volume of a sphere given radius 5; (c) the
volume of a
pyramid whose height is 4 and whose base is a square with dimensions 2
by 3. Once all values are calculated, you should output the statement "The
XXXX has the largest volume of YYYY" where XXXX is the shape that had the
largest volume, and YYYY is the actual volume as calculated in steps (a),
(b), or (c).
- [20 pts.] Write a program that determines whether a
String value starts and ends with the same letter. (Ignore capitalization,
thus 'A' should be the same letter as 'a'). Your program must follow the
design recipe introduced in class on Friday Oct-27 and described on the
course web page for design recipes.
Your program should output on a single line the statement "The word starts
and ends with the same letter" if the String value does, and "The word does
not start and end with the same letter" if the String value doesn't.
- [20 pts.] Write a program that uses a while
loop that prints a table of temperature conversions from Celsius to
Fahrenheit. Note that the order of the output is in reverse order from 40
degree Celsius down to -10 degrees Celsius.
The table output should look like the following:
Celsius : Fahrenheit
--------------------
40 : 104.0
39 : 102.2
38 : 100.4
37 : 98.6
36 : 96.8
35 : 95.0
34 : 93.2
...
-5 : 23.0
-6 : 21.2
-7 : 19.4
-8 : 17.6
-9 : 15.8
-10 : 14.0 |
- [20 pts.] Write a program to read from the keyboard
two lines of input. Each line is prompted by a statement "Enter Line #:".
The input will contain a sequence of characters which was terminated by the
user pressing "Enter/Return". Your program should print out the statement
"Line 2 is a reverse of Line 1" if the sequence of characters for Line 2 are
the reverse of Line 1; Otherwise, output "No Comparison". For example, a
sample run of your program is shown below:
Enter Line 1:
This is the Line
Enter Line 2:
eniL eht si sihT
Line 2 is a reverse of Line 1 |
- [20 pts.] Write a program that reads a set of
integers, one per line, until the end of input has been reached (in Eclipse,
this is done by typing "Control-Z" in the Console window. You can assume
that at least two numbers will be typed in. Once all integers have been
read, your program should output from this set of numbers: (a) the minimum
number; (b) the maximum number; and (c) the total sum of all numbers
entered. For example,
10
20
33
-8
<Control-Z pressed here>
Minimum: -8
Maximum: 33
Sum: 55 |
Optional Non-Graded
- Extra questions (ungraded) may appear here.
Deliverables
Your goal is to turnin the
Project files by Tuesday October 31st at 10:00 AM Further details will be
posted HERE showing the preferred means of uploading your solution to the TAs.
Please be aware that no late homeworks will be accepted. This means that we will
grade as zero any homework not submitted by the above turnin means.
Notes
- Any updates to the homework will be described here,
with timestamps.
- [10/27 2:54 PM] Homework1 completed and ready to go.
- [10/29/2006 5:34 PM] Note that the String example for
problem 4 must treat lower case 'a' and upper case 'A' as different letters.
I fixed the example (note the capital T in red) to properly reflect this.
©2006 George T. Heineman