![]() |
![]() |
|
home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
Due Feb.08 (Fri): Problems 1-12; only hardcopy is needed.
Due Feb.11 (Mon): Problems 13-15, the html-documentation only (signatures, javadoc, and test cases). Turn in a hard-copy in class and also electronically submit (on WebCT) a copy of the java file.
(Note that the javadoc has already been completed for you this week; although you can put a comment with an @author tag preceding the class declaration.)
Due Feb.13 (Wed): Problems 14-15, implementation (Java code).
Note that you can consider this homework of studying for the exam.
2 + bob.gloopz( "Tuesday", false ) |
double roundTripTime( String url, int portNumber ) |
double weight = 30; boolean enjoysAnts = true; double mph = 30; String guess; if (weight > 100) { if (enjoysAnts) { guess = "aardvark"; } else { guess = "buffalo"; } } else { if (mph >= 30) { guess = "cheetah"; } else { guess = "dik-dik"; } } |
boolean outOfBounds( int i ) { return ((i < 0) || (i >= 100)); } |
/** Given a number of cents, return a String for that amount in dollars, * but expressed in a very odd way, as shown in the tests below. * @param cents An amount of money (in cents). * @return A String representing that amount, in dollars. * Examples (assuming that `c` is a Cashier): * c.centsToStringOdd(579) = "dollars 5, and cents 79" * c.centsToStringOdd(148) = "dollars 1, and cents 48" (Note "dollars 1" is okay grammar, in this odd phrasing) * c.centsToStringOdd( 8) = "dollars 0, and cents 08" (Note that we return the character '0' in front of the '3'!) * c.centsToStringOdd( ) = * c.centsToStringOdd( ) = * c.centsToStringOdd( ) = */ |
/** Given a number of cents, return a String for that amount in dollars, * including a preceding dollar-sign, * but using a (european-style) decimal-comma rather than a decimal-point. * @param cents An amount of money (in cents). * @return A String representing that amount, in dollars. Use a comma * for the decimal-separator. * Examples (assuming that `c` is a Cashier): * c.centsToStringEuroStyle(579) = "$5,79 * c.centsToStringEuroStyle( 48) = "$0,48" * c.centsToStringEuroStyle( ) = * c.centsToStringEuroStyle( ) = * c.centsToStringEuroStyle( ) = */ |
/** Respond to a donut order, at Oh Bonnie Pain. * @param nombreDonuts The number of donuts ordered. Non-negative. * @return A sophisticated-sounding message reporting the total price. * Tests (presuming `c` is a Cashier): * c.donutOrderrier( 10 ) = "10 sucrebombe donuts will cost $8,50. Merci!" * c.donutOrderrier( ) = * c.donutOrderrier( ) = */ |
Extra Credit: (4pts test cases/docs; 4pts code; due with part (c))
Write a function centsToString
which is more flexible than either
centsToStringEuroStyle
or
centsToStringOdd:
It takes in three arguments:
a number of cents,
and what text used to indicate the currency,
and a decimal separator (a String).
Now, rewrite the body
of centsToStringEuroStyle with just one short line:
Also, write the body of centsToStringOdd with just one short line:
home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
©2008, Ian Barland, Radford University Last modified 2008.Feb.13 (Wed) |
Please mail any suggestions (incl. typos, broken links) to ibarland ![]() |
![]() |