|
home—info—lects—labs—exams—hws
textbook—tutor/PIs—java.lang docs—java.util docs
Work on today's lab with a partner. You can write the following two-to-three methods in a class named, say, ebayExpert.
If you sell an item on eBay, you are charged several different fees. Today, we will compute one of those: the “final-value fee”, which depends on how much the item sold for (its “sale price”).
(Note that there is also a flat fee just for using eBay to start with, as well as an optional extra fee if you want some fancy pictures in your listing. We'll handle those other fees in a future lab.) The final value fee is 8.75% of the (up to) first $25 of the sale price, and 3.50% of the rest of the sale price.
class EbayExpert { /** computeFVFee computes the final-value fee which eBay charges to a seller. * @param ________ _______________ * @return _____________________, in dollars. */ ______ computeFVFee( ______ _______ ) { return 56.78; // A dummy, stub result. } } |
The above problem was simplified a bit;
eBay's final-value-fee doesn't have just the two tiers
(0.00, 25.00] and (25.00,+∞),
but actually three: (0.00,25.00], (25.00,1000.00], and (1000.00,+∞).
Those round and square parentheses are math-ese for intervals with open and
closed endpoints; eBay presents this same information
in a table.
Go back and change your program to use eBay's actual final-value-fee.
Use the if-else-if statement, for this three-tier problem. Match up those curly-brackets carefully!
Modify your program to account for two additional fees:
home—info—lects—labs—exams—hws
textbook—tutor/PIs—java.lang docs—java.util docs
©2009, Ian Barland, Radford University Last modified 2009.Mar.03 (Tue) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |