In: Computer Science
// 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 a
// name, e.g "French toast", and a price
public Breakfast(string name, double price)
{
Name = name;
Price = price;
}
public string Name {get; set;}
public double Price {get; set;}
}
I need help to Fixed bug(s) in Breakfast class
The provided file has syntax and/or logical errors. Determine the problem(s) and fix the program. C#
Screenshot of the modified code:
Sample output:
Code to copy:
// Creates a Breakfast class
// and instantiates an object
// Displays Breakfast special information
using static System.Console;
class DebugNine2
{
static void Main()
{
//syntax error: quote is missing
Breakfast special = new Breakfast("French toast", 4.99);
//Display the info about breakfast
WriteLine(special.INFO);
// then display today's special
//logical error: {0} and syntax error: special.Name
WriteLine("Today we are having {0} for {1}",
special.Name, special.Price.ToString("C2"));
}
}
class Breakfast
{
public string INFO =
"Breakfast is the most important meal of the day.";
// Breakfast constructor requires a
// name, e.g "French toast", and a price
public Breakfast(string name, double price)
{
Name = name;
Price = price;
}
public string Name { get; set; }
public double Price { get; set; }
}
-------------------------------------
Please give me a UPVOTE. Thank you :)