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...
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:...
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...
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()...
C++ QUESTION ABOUT FIXING CODE AND RUNNING TESTS: class SpeakerSystem { public: void vibrateSpeakerCones(unsigned signal) const...
C++ QUESTION ABOUT FIXING CODE AND RUNNING TESTS: class SpeakerSystem { public: void vibrateSpeakerCones(unsigned signal) const { cout << "Playing: " << signal << "Hz sound..." << endl; cout << "Buzz, buzzy, buzzer, bzap!!!\n"; } }; class Amplifier { public: void attachSpeakers(const SpeakerSystem& spkrs) { if(attachedSpeakers) cout << "already have speakers attached!\n"; else attachedSpeakers = &spkrs; }    void detachSpeakers() { // should there be an "error" message if not attached? attachedSpeakers = nullptr; }    void playMusic( ) const...
Please correct my grammar's mistakes :) Please correct my grammar's mistakes, thanks! I chose to interview...
Please correct my grammar's mistakes :) Please correct my grammar's mistakes, thanks! I chose to interview Dinh, who is an active, assertive person and a business major at ACC. Although he is not a math and science major, he has already taken a lot of different science and math classes. These classes include algebra, general chemistry one and two, general physics one and two, and geometry, etc. Right now, he is taking statistics and investments. Dinh told me that he...
Implement in C++ Design a BookstoreManager class which creates a dynamic array of type Book (don’t...
Implement in C++ Design a BookstoreManager class which creates a dynamic array of type Book (don’t use vectors), and provide an implementation for the following operations on books in the array 1)isEmpty() returns true if the array is empty, otherwise false 2)isFull() returns true if the array is full, otherwise false 3)listSize() prints the number of books in the array 4)print() prints the content of the array 5)insert(Book) asks the user to enter new book info, and it adds the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT