Question

In: Computer Science

please debug this by fixing all the mistakes in C# // Creates a BoatLicense class //...

please debug this by fixing all the mistakes in C#

// 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 200801
using System;
public class DebugSeven4
{
   public static void Main()
   {
      const int STARTINGNUM = 200801;
      BoatLicense[] license = new BoatLicense[3];
      int x;
      for(x = 0; x < license.Length; ++x)
      {
         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 < Length; ++x)
        Display(license[x]);
   }
   static void Display(BoatLicense lic)
   {
      Console.WriteLine("Boat #{0} from {1} has a {2} HP motor.",
         lic[x].LicenseNum, lic.State, MotorSizeInHP);
      Console.WriteLine("    The price for the license is {0}\n",
         lic.price.ToString("C2"));
   }
}
class BoatLicense
{
      public const static HPCUTOFF = 50;
      public const static LOWFEE = 25.00;
      public const static HIGHFEE = 38.00;
      private string licenseNum;
      private string state;
      private int motorSizeInHP;
      private double price;
      public string LicenseNum
      {
         let
         {
            return licenseNum;
         }
         set
         {
            licenseNum = value;
         }
      }
      public string State
      {
         set
         {
            state = value;
         }
      }
      public int MotorSizeInHP
      {
         bet
         {
            return motorSizeInHP;
         }
         set
         {
            motorSizeInHP = value;
            if(MotorSizeInHP > HPCUTOFF)
               price = LOWFEE;
            else
               price = HIGHFEE;
         }
      }
      public double Price
      {
         get
         {
            return price;
         }
      }

   }

Solutions

Expert Solution

// 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 200801
using System;
public class DebugSeven4
{
   public static void Main()
   {
      const int STARTINGNUM = 200801;
      BoatLicense[] license = new BoatLicense[3];
      int x;
      for(x = 0; x < license.Length; ++x)
      {
         license[x] = new BoatLicense();
         license[x].LicenseNum = (x + STARTINGNUM).ToString();
      }
      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]);
   }
   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}\n",
         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;
         }
      }

   }
**************************************************

Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.

Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.


Related Solutions

please debug this by fixing all the mistakes in C#: // Creates a Breakfast class //...
please debug this by fixing all the mistakes in C#: // Creates a Breakfast class // and instantiates an object // Displays Breakfast special information using System; public class DebugSeven2 {    Breakfast special = new Breakfast("French toast", 4.99);    //Display the info about breakfast    Console.WriteLine(Breakfast.info);    // then display today's special    Console.WriteLine("Today we are having {0} for {1}",       special.Name, special.Price.ToString("C2")); } class Breakfast {    // info is class field    public static string info =...
please debug this code by fixing all the mistakes. thank you. // Creates a HomeworkAssignment class...
please debug this code by fixing all the mistakes. thank you. // Creates a HomeworkAssignment class // instantiates two objects // and prompts the user for infromation about two courses using System; public class DebugSeven1 {     public static void Main()     {         HomeworkAssignment course1;         HomeworkAssignment course2;         string entryString;         int exercises;         // Get info for first class         Console.Write("What class do you have homework for? ");         entryString = Console.ReadLine(); // Fixed .ReadLine         course1.ClassName...
Please debug this by fixing all the mistakes so it will compile in C# // Program...
Please debug this by fixing all the mistakes so it will compile in C# // Program prompts user for any number of values // (up to 20) // and averages them using System; public class DebugFive04 {     public static void Main()     {         const int QUIT = 999;         int[] numbers = new int[20];         int x;         int num;         double average;         double total;         string inString; // intString         Console.Write("Please enter a number or "...
Debug please. It's in C++ #include<iostream> #include<string> using namespace std; class Prescription {    friend ostream&...
Debug please. It's in C++ #include<iostream> #include<string> using namespace std; class Prescription {    friend ostream& operator<<(ostream&, const Prescription&);    friend istream& operator>>(istream&, Prescription&);    private: int idNum; int numPills; double price;    public: Prescription(const int = 0, const int = 0, const double = 0.0); }; Prescription::Prescription(const int id, const int pills, const double p) {    id = id;    numPills = pills;    price = p; } ostream& operator<<(ostream& out, const Prescription pre) {    out <<...
in C++ Requirements: Write a program that creates a new class called Customer. The Customer class...
in C++ Requirements: Write a program that creates a new class called Customer. The Customer class should include the following private data: name - the customer's name, a string. phone - the customer's phone number, a string. email - the customer's email address, a string. In addition, the class should include appropriate accessor and mutator functions to set and get each of these values. Have your program create one Customer objects and assign a name, phone number, and email address...
Debug please. It's in C++ #include<iostream> #include<string> using namespace std; template <class T> double half(int x)...
Debug please. It's in C++ #include<iostream> #include<string> using namespace std; template <class T> double half(int x) { double h = x / 2; return h; } class TuitionBill { friend ostream& operator<<(ostream, TuitionBill); private: string student; double amount; public: TuitionBill(string, double); double operator/(int); }; TuitionBill::TuitionBill(string student, double amt) { student = student; amount = amt; } double TuitionBill::operator/(int factor) { double half = amount / factor; return hafl; } ostream& operator<<(ostream& o, TuitionBill) { o << t.student << " Tuition:...
please debug this so that it will compiler: C# // Uses PrintWebAddress method three times using...
please debug this so that it will compiler: C# // Uses PrintWebAddress method three times using System; public class DebugSix2 {    public void Main()    {       PrintWebAddress();       Console.WriteLine("Shop at Shopper's World");       PrintWebAddresses();       Console.WriteLine("The best bargains from around the world");       PrintWebAddress;    }    public void PrintWebAddress()    {       Console.WriteLine(------------------------------");       Console.WriteLine(Visit us on the web at:");       Console.WriteLine(www.shoppersworldbargains.com");       Console.WriteLine(******************************");    } }
Alex makes mistakes in class according to Poisson process with an average rate of 1.4 mistakes...
Alex makes mistakes in class according to Poisson process with an average rate of 1.4 mistakes per class. a. What is the probability that Alex makes at least 3 mistakes during one class? Round your answer to 4 significant figures. b. What is the probability that Alex makes exactly 12 mistakes during two weeks of classes (that is, during 6 classes, since Alex teaches a MWF lecture)? Round your answer to 4 significant figures. c. What is the probability that...
To be Completed in C# Write a program that creates an exception class called ManyCharactersException, designed...
To be Completed in C# Write a program that creates an exception class called ManyCharactersException, designed to be thrown when a string is discovered that has too many characters in it. Consider a program that takes in the last names of users. The driver class of the program reads the names (strings) from the user until the user enters "DONE". If a name is entered that has more than 20 characters, throw the exception. Design the program such that it...
Write a C++ program that creates a base class called Vehicle that includes two pieces of...
Write a C++ program that creates a base class called Vehicle that includes two pieces of information as data members, namely: wheels (type int) weight (type float) Program requirements (Vehicle class): Provide set and a get member functions for each data member. Your class should have a constructor with two parameters (one for each data member) and it must use the set member functions to initialize the two data members. Provide a pure virtual member function by the name displayData()...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT