Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

// Creates a BoatLicense class // And instantiates three BoatLicense objects //

ID: 3545978 • Letter: #

Question

// Creates a BoatLicense class

// And instantiates three BoatLicense objects

// The price of a licence is $25 if the boat motor is 50 HP or under

// and $38 if the HP is over 50

// Boat licenses are issued with numbers starting with 201401

using System;

class FixedDebugNine4

{

    static void Main()

   {

      const int STARTINGNUM = 201401;

      BoatLicense[] license = new BoatLicense[];

      int x;

      for(x = 0; x < license.Length; ++x)

      {

         license[x] = new BoatLicense();

         license[x].LicenseNum = ("" + x + STARTING_NUM);

      }

      license[0].State = "WI";

      license[1].State = "MI";

      license[2].State = "MN";

      license[0].MotorSizeInHP = 30;

      license[1].MotorSizeInHP = 50;

      license[2].MotorSizeInHP = 100;

      for(x = 0; x < license.length; ++x)

        Display(license[x]);

   }

    internal static void Display(BoatLicense lic)

   {

      Console.WriteLine("Boat #{0} from {1} has a {2} HP motor.",

         lic.LicenseNum, lic.State lic.MotorSizeInHP);

      Console.WriteLine("    The price for the license is {0} ",

         lic.Price.ToString("C2"));

   }

}

class BoatLicense

{

    public const int HPCUTOFF = 50;

    public const double LOWFEE = 25.00;

    public const double HIGHFEE = 38.00;

    private string licenseNum;

    private string state;

    private int motorSizeInHP;

    private double price;

    public string LicenseNum

    {

        get

        {

            return licenseNum;

        }

        set

        {

            licenseNum = Lic;

        }

    }

    public string State

    {

        get

        {

            return state;

        }

        set

        {

            State = value;

        }

    }

    public int MotorSizeInHP

    {

        get

        {

            return motorSizeInHp;

        }

        set

        {

            motorSizeInHP = value;

            if (MotorSizeInHP != HPCUTOFF)

                price = LOWFEE;

            else

                price = HIGHFEE;

        }

    }

    public double Price

    {

        get

        {

            return price;

        }

    }


}

Explanation / Answer

Sample Output



Boat #0201401 from WI has a ?30.00 HP motor.

The price for the license is ?25.00


Boat #1201401 from MI has a ?50.00 HP motor.

The price for the license is ?38.00


Boat #2201401 from MN has a ?100.00 HP motor.

The price for the license is ?25.00








Code



// Creates a BoatLicense class

// And instantiates three BoatLicense objects

// The price of a licence is $25 if the boat motor is 50 HP or under

// and $38 if the HP is over 50

// Boat licenses are issued with numbers starting with 201401

using System;

class FixedDebugNine4

{

static void Main()

{

const int STARTINGNUM = 201401;

BoatLicense[] license = new BoatLicense[3];

int x;

for(x = 0; x < license.Length; ++x)

{

license[x] = new BoatLicense();

license[x].LicenseNum = ("" + x + STARTINGNUM);

}

license[0].State = "WI";

license[1].State = "MI";

license[2].State = "MN";

license[0].MotorSizeInHP = 30;

license[1].MotorSizeInHP = 50;

license[2].MotorSizeInHP = 100;

for(x = 0; x < license.Length; ++x)

Display(license[x]);

}

internal static void Display(BoatLicense lic)

{

Console.WriteLine("Boat #{0} from {1} has a {2} HP motor.",lic.LicenseNum,lic.State, lic.MotorSizeInHP.ToString("c2"));


Console.WriteLine(" The price for the license is {0} ",lic.Price.ToString("C2"));

}

}













class BoatLicense

{

public const int HPCUTOFF = 50;

public const double LOWFEE = 25.00;

public const double HIGHFEE = 38.00;

private string licenseNum;

private string state;

private int motorSizeInHP;

private double price;

public string LicenseNum

{

get

{

return licenseNum;

}

set

{

licenseNum = value;

}

}

public string State

{

get

{

return state;

}

set

{

state = value;

}

}

public int MotorSizeInHP

{

get

{

return motorSizeInHP;

}

set

{

motorSizeInHP = value;

if (MotorSizeInHP != HPCUTOFF)

price = LOWFEE;

else

price = HIGHFEE;

}

}

public double Price

{

get

{

return price;

}

}


}