Homework Assignment 2A

Selection Structures

Due Date Wednesday, February 25, 2004

Convert the if structure inside the method licenseFee from a compound to a nested structure.  Write the whole method.

public static double licenseFee (int year, String type) {

double lincenseCost = 0;

if (year < 1997 && type.equals ("Truck"))
    licenseCost = 85.00;
if (year < 1997 && type.equals ("Car"))
    licenseCost = 75.00;
if (year < 1997 && type.equals ("Compact"))
    licenseCost = 65.00;
if (year > 1997 && type.equals ("Truck"))
    licenseCost = 80.00;
if (year > 1997 && type.equals ("Car"))
    licenseCost = 70.00;
if (year > 1997 && type.equals ("Compact"))
    licenseCost = 60.00;

return licenseCost;

}


Hosted by www.Geocities.ws

1