Question

In: Computer Science

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 =
      "Breakfast is the most important meal of the day.";
   private string name;
   private double price;
   // Breakfast constructor requires a
   // name, e.g "French toast", and a price
   private Breakfast(string name, double price)
   {
       Name = Name;
       price = price;
   }
   public string Name
   {
      get
      {
          return Name;
      }
      set
      {
          value = name;
      }
    }
    public double Price
    {
       get
       {
          return price;
       }
       setUp
       {
          price = value;
       }
    }
}

Solutions

Expert Solution

CODE

// Creates a Breakfast class

// and instantiates an object

// Displays Breakfast special information

using System;

public class DebugSeven2

{

public static void Main (string[] args) {

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 =

"Breakfast is the most important meal of the day.";

private string name;

private double price;

// Breakfast constructor requires a

// name, e.g "French toast", and a price

public Breakfast(string name, double price)

{

this.name = name;

this.price = price;

}

public string Name

{

get

{

return Name;

}

set

{

value = name;

}

}

public double Price

{

get

{

return price;

}

set

{

price = value;

}

}

}



Related Solutions

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 =...
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...
// Creates a Breakfast class // and instantiates an object // Displays Breakfast special information using...
// Creates a Breakfast class // and instantiates an object // Displays Breakfast special information using System; using static System.Console; using System.Globalization; class DebugNine2 {    static void Main()    {       Breakfast special = new Breakfast("French toast", 4.99);       //Display the info about breakfast       WriteLine(special.INFO);       // then display today's special       WriteLine("Today we are having {0} for {1}",          special.Name, special.Price.ToString("C2", CultureInfo.GetCultureInfo("en-US")));   } } class Breakfast {    public string INFO =       "Breakfast is the most important meal of the day.";       // Breakfast constructor requires...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT