|
home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
Due Date: Jan.29 (Mon.), 17:00.
/** Convert meters into feet. * @param meters A distance, in meters. * @return that same distance, as measured in feet. */ double metersToFeet( double meters ) { double cm; cm = meters * 100; double inches; inches = cm / 2.54; // This is the only metric length conversion I know! return inches/12; } |
/** Convert feet into furlongs. * @param feet A distance, in feet. * @return that same distance, as measured in furlongs. */ double feetToFurlongs( double feet ) { return (feet / 3) / 220; // Dividing by 3 gives us yards; dividing yards by 220 gives us furlongs. } |
1 /** Calculate the are of *crust* on a pizza, given its diameter. 2 * Krusteaze pizza has 3" of crust all the way around. 3 * @param diam The diameter of the pizza (in inches); must be 6 or more. 4 * @return The amount of crust (in square inches) 5 * p.crustArea( 6) = p.pizzaArea( 6) - p.toppingArea( 6) =~ 28.26 6 * p.crustArea(12) = p.pizzaArea(12) - p.toppingArea(12) =~ 84.78 7 * p.crustArea(20) = p.pizzaArea(20) - p.toppingArea(20) =~ 160.14 8 */ 9 double crustArea( double diam ) { 10 double totalArea; 11 totalArea = this.pizzaArea(diam); 12 13 double innerArea; 14 innerArea = this.toppingArea(diam); 15 16 return (totalArea - innerArea); 17 } |
/** Look up how many credit-hours a course is. * @param deptName The name of a department (the four-letter abbreviation). * @param courseNumber The number of a course, . * @return The number of credit-hours for that course is worth. */ |
/** Determine whether a student is allowed to register for a particular course. * @param studentID A student's ID number. * @param deptName The name of a department (the four-letter abbreviation). * @param courseNumber The number of a course. * @return whether or not the named student is allowed to enroll in the course. */ |
vj.announceWinner( "beachfront boppers", 21, "valley volleyers", 15 ) = "beachfront boppers won!" vj.announceWinner( "beachfront boppers", 15, "valley volleyers", 21 ) = "valley volleyers won!" vj.announceWinner( "beachfront boppers", 21, "valley volleyers", 20 ) = "game still in progress." |
1Remember that while “local variable” and “parameter” are very similar concepts, they are technically different from each other. ↩
2 It is mildly unsatisfying, aesthetically, that we hand the judge four independent inputs, even though really we have in mind two name/score pairs. We'd prefer to somehow bundle together the name and score of each team, and then just hand the judge those two bundles. Don't worry, we'll see how to bundle related information together in a week 4. ↩
3Recall from lab01b, that the upper-right window can switch between these views. If you get an error when trying the interface view, check the class message boards for possible solutions. ↩
home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
©2007, Ian Barland, Radford University Last modified 2007.Aug.27 (Mon) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |