2006 Taxable Item

<< 2006TimeIntervalAppointment | APQuestionsTrailIndex | 2006Customer >>

Question from the College Board

VehicleTester

public class VehicleTester
{
  public static String round(double d)
  {
      int dol=(int)Math.floor(d);
      int c=(int)(Math.floor(100.0*d)-100*dol);
      String dollars=Integer.toString(dol);
      String cents=Integer.toString(c);
      if (cents.length()==1) cents="0"+cents;
      return "$"+dollars+"."+cents;
  }
  public static void main(String[] args)
  {
    Vehicle car = new Vehicle(20000.0, 2500.0, 0.1);
    System.out.println("20000, 2500, 0.1 ==> purchase price: "+ round(car.purchasePrice()));
    System.out.println("List is 22500, purchasePrice should be 24750");
    car.changeMarkup(1000);
    System.out.println("Changed markup to 1000 ==> purchase price: "+ round(car.purchasePrice()));
    System.out.println("(Should be $30800.00)");

   Vehicle car2 = new Vehicle(20000.0, 2500.0, 0.1);
    System.out.println("20000, 2500, 0.1 ==> purchase price: "+ round(car2.purchasePrice()));
    car2.changeMarkup(1000);
    System.out.println("Changed markup to 1000 ==> purchase price: "+ round(car2.purchasePrice()));
    System.out.println("(Should be $23100.00)");
  }
}

Item

public interface Item
{
  double purchasePrice();
}

TaxableItem

public abstract class TaxableItem implements Item
{
  private double taxRate;


  public abstract double getListPrice();


  public TaxableItem(double rate)
  {  taxRate = rate;  }



  public double purchasePrice()
  {
    //part a here
  }
}

Vehicle

  //part b

public class Vehicle 
{


  public void changeMarkup(double markup)
  {

  }
}