RU beehive logo ITEC dept promo banner
ITEC 120
2009spring
ibarland
nokie
jmdymacek

homeinfolectslabsexamshws
textbooktutor/PIsjava.lang docsjava.util docs

lab09a
eBay revisited

Previously, wrote code to compute the final value fee for eBay auctions. However, there are more types of fees:

Here are test cases for you:
    class EbayExpertTester
    {
      public static void main( String[] args )
      {
        EbayExpert ee = new EbayExpert();
        
        System.out.println( "Testing computeFVFee" );
        System.out.println( ee.computeFVFee(0)    + " expected $0.0" );
        System.out.println( ee.computeFVFee(10)   + " expected $0.875" );
        System.out.println( ee.computeFVFee(25)   + " expected $2.1875" );
        System.out.println( ee.computeFVFee(35)   + " expected $2.5375" );
        System.out.println( ee.computeFVFee(1000) + " expected $36.3125" );
        System.out.println( ee.computeFVFee(1010) + " expected $36.4625" );
    
        System.out.println( "Testing galleryFee" );
        System.out.println( ee.galleryFee(true)  + " expected $0.35" );
        System.out.println( ee.galleryFee(false) + " expected $0.0" );
    
        System.out.println( "Testing totalFee" );
        System.out.println( ee.totalFee(0,false)    + " expected $0.1" );
        System.out.println( ee.totalFee(10,false)   + " expected $0.975" );
        System.out.println( ee.totalFee(25,false)   + " expected $2.2875" );
        System.out.println( ee.totalFee(35,false)   + " expected $2.6375" );
        System.out.println( ee.totalFee(1000,false) + " expected $36.4125" );
        System.out.println( ee.totalFee(1010,false) + " expected $36.5625" );
    
        System.out.println( ee.totalFee(0,true)    + " expected $0.45" );
        System.out.println( ee.totalFee(10,true)   + " expected $1.325" );
        System.out.println( ee.totalFee(25,true)   + " expected $2.6275" );
        System.out.println( ee.totalFee(35,true)   + " expected $2.9875" );
        System.out.println( ee.totalFee(1000,true) + " expected $36.7625" );
        System.out.println( ee.totalFee(1010,true) + " expected $36.9125" );
    
        System.out.println( "Testing wasProfitable" );
        System.out.println( ee.wasProfitable(0,false) + " expected false" );
        System.out.println( ee.wasProfitable(0,true) + " expected false" );
        System.out.println( ee.wasProfitable(0.25,false) + " expected true" );
        System.out.println( ee.wasProfitable(0.25,true) + " expected false" );
        System.out.println( ee.wasProfitable(0.45,false) + " expected true" );
        System.out.println( ee.wasProfitable(0.45,false) + " expected true" );
        System.out.println( ee.wasProfitable(0.49,true) + " expected false" );
        System.out.println( ee.wasProfitable(0.49,true) + " expected false" );
        System.out.println( ee.wasProfitable(0.50,false) + " expected true" );
        System.out.println( ee.wasProfitable(0.50,true) + " expected true" );
        System.out.println( ee.wasProfitable(10,true) + " expected true" );
        System.out.println( ee.wasProfitable(10,false) + " expected true" );
        }
    
    }

You may use your previous code for the Final Value Fee; if you didn't finish that, here is a version you can use:

class EbayExpert {


  /** computeFVFee computes the final-value fee which eBay charges to a seller.
   *  @param salePrice    How much the item was auctioned for.
   *  @return The Final Value Fee, in dollars.
   */
  double computeFVFee( double salePrice ) 
  {
    final double FV_THRESH_LOW = 25.00; // Final Value threshhold between 'low' and 'medium' rate.
    final double FV_THRESH_MED = 1000.00; // Final Value threshhold between 'medium' and 'high' rate.
    final double FV_RATE_LOW  = 0.0875;  // Final Value rate, applies up to FV_THRESH_LOW.
    final double FV_RATE_MED  = 0.0350;  // Final Value rate, applies after FV_THRESH_LOW.
    final double FV_RATE_HIGH = 0.0150;  // Final Value rate, applies after FV_THRESH_MED.

    if (salePrice <= FV_THRESH_LOW)
    {
      return FV_RATE_LOW  * salePrice;
    }
    else if (salePrice <= FV_THRESH_MED) 
    {
      return FV_RATE_LOW  * FV_THRESH_LOW
           + FV_RATE_MED  * (salePrice - FV_THRESH_LOW);
    }
    else
    {
      return FV_RATE_LOW  * FV_THRESH_LOW
           + FV_RATE_MED  * (FV_THRESH_MED - FV_THRESH_LOW) 
           + FV_RATE_HIGH * (salePrice - FV_THRESH_MED);
    }
  }

}


1 EBay lists this under “Listing Upgrade Fees”      

2Well, it's only a flat fee for auctions whose starting price is a penny. But really, all auctions should start there, and let the market determine the price, without any input from the seller.      

homeinfolectslabsexamshws
textbooktutor/PIsjava.lang docsjava.util docs


©2009, Ian Barland, Radford University
Last modified 2009.Mar.25 (Wed)
Please mail any suggestions
(incl. typos, broken links)
to iba�rlandrad�ford.edu
Powered by PLT Scheme