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...
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 "...
// 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:...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT