RU beehive logo ITEC dept promo banner
ITEC 120
2010fall
ibarland

homeinfolectslabsexamshws
tutor/PIsObject120 + its docsjava.lang docsjava.util docs

lab04b
if-else-if; helper functions
eBay fees

We will spend 5min discussing the syntax of if-else-if, and how you should always end with an else {}, whether the overall if is initializing a variable or returning a value.

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 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).

Write a function totalEbayFee, so that eBay knows how much to charge each seller, when an auction finishes.

  1. What two pieces of information does totalEbayFee need to know, so that it can determine the answer?
  2. What Java data type is the best way to represent these pieces of info?
  3. Write the signature for totalEbayFee, followed by the javadoc comments and some test cases.
  4. 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.

  5. 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.

homeinfolectslabsexamshws
tutor/PIsObject120 + its docsjava.lang docsjava.util docs


©2010, Ian Barland, Radford University
Last modified 2010.Sep.30 (Thu)
Please mail any suggestions
(incl. typos, broken links)
to iba�rlandrad�ford.edu
Powered by PLT Scheme