home—info—lects—labs—exams—hws
D2Ltutor/PIs—zoom (snow day)
Object120 + its docs—java.lang docs—java.util docs
if-else-if; helper functions
eBay fees
Today (Tue) and Thurs we will complete the lab below.
Your goal for today is to
(a) understand the problem,
(b) complete test-cases for totalEbayFee (and writing a stub function for it),
(c) write test-cases for computeFVFee (and writing a stub function for it).
Then, on Thursday, you'll finish up by completing the function-bodies for your two functions.
Do not start writing a function body before you have finished test cases for that function!
We will not help you with writing function-bodies unless we see several tests for it first.
We will also go through the creation of one test case for
totalEbayFee,
and
computeFVFee
(discussing why the percentages are tiered the way they are).
Work on today's lab with a partner.
You can write the following two-to-three methods in a class named, say, class EbayExpert.
Calculating eBay fees
If you sell an item on eBay, you are charged a fee.
That total, overall fee is comprised of several parts:
Your task:
You want to sell a bunch of your old books, DVDs, movies, and video games
on eBay,
and you'd like a program to calculate how much you'll owe eBay after
auctioning an item for some amount
selling an item in their fixed price format
(more commonly called buy it now
— not an auction).
Note that fixed price items have to be listed at at least $0.99 (never less).
(Alternately:
you're writing the code that eBay itself uses,
to decide how much to charge a seller after an auction finishes.)
Write a function totalEbayFee, so that eBay knows how much to
charge each seller, when an auction finishes.
-
What two pieces of information does totalEbayFee need to know,
so that it can determine the answer?
-
What Java data type is the best way to represent these pieces of info?
-
Write the signature for
totalEbayFee,
followed by the javadoc comments and some test cases.
Holy Smokes!
Computing the overall fee has several parts;
the part computing the final value fee is a sizeable task in itself!
We will break this task into its own sub-function,
which totalEbayFee will call as a helper function.
Make test cases, signature, javadoc, and stub for
computeFVFee.
- Only after doing the above, write the body of the functions.
Note that the test cases help you, to figure out
how to compute the answer.
Hint:
You can write the body of totalEBayFee very easily
once you can use computeFVFee.
Here is a general skeleton of a solution for this problem.
home—info—lects—labs—exams—hws
D2Ltutor/PIs—zoom (snow day)
Object120 + its docs—java.lang docs—java.util docs
 This page licensed CC-BY 4.0 Ian Barland Page last generated | Please mail any suggestions (incl. typos, broken links) to ibarland radford.edu |
 |