Creates a Breakfast class

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter12: Exception Handling
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question

The provided file has syntax and/or logical errors. Determine the problem(s) and fix the program.

// 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; }
}
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT