Question

In: Computer Science

// 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 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#

Solutions

Expert Solution

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 :)


Related Solutions

Create the logic for an application that instantiates an object of the ATM class. Prompt the...
Create the logic for an application that instantiates an object of the ATM class. Prompt the user for the ATM object data to display the user’s bank balance PROGRAMMING LOGIC AND DESIGN QUESTION JAVA LANGUAGE
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 =...
CODE IN JAVA: Write a ProductTester class that creates one Product object named "Juicer" with a...
CODE IN JAVA: Write a ProductTester class that creates one Product object named "Juicer" with a price of $50.99, prints the name and price of the product, reduces its price by 4.0, and then prints its price again. public class Product { private String name; private double price; public Product(String productName, double productPrice) { name = productName; price = productPrice; } public String getName() { return name; } public double getPrice() { return price; } public void reducePrice(double amount) {...
Purpose: To write an Object-Oriented application that creates a Java class with several instance variables, a...
Purpose: To write an Object-Oriented application that creates a Java class with several instance variables, a constructor to initialize the instance variables, several methods to access and update the instance variables’ values, along with other methods to perform calculations. Also, write a test class that instantiates the first class and tests the class’s constructor and methods. Details: Create a class called Rectangle containing the following: Two instance variables, An instance variable of type double used to hold the rectangle’s width....
1. A constructor is a special Class member method. It is automatically called when an object...
1. A constructor is a special Class member method. It is automatically called when an object of the class is created. It can also be called more than once after the object is created. 2. In Java, the new operator is used to create an instance/object of a class in the heap. 3. A reference variable is a memory location contains an address of an object stored in the stack. 4. Encapsulation and abstraction are both the pillars of Object-Oriented...
Using Java preferably with Eclipse Task: Write a program that creates a class Apple and a...
Using Java preferably with Eclipse Task: Write a program that creates a class Apple and a tester to make sure the Apple class is crisp and delicious. Instructions: First create a class called Apple The class Apple DOES NOT HAVE a main method Some of the attributes of Apple are Type: A string that describes the apple.  It may only be of the following types:  Red Delicious  Golden Delicious  Gala  Granny Smith Weight: A decimal value representing...
Create a program that: Creates a sales receipt, displays the receipt entries and totals, and saves...
Create a program that: Creates a sales receipt, displays the receipt entries and totals, and saves the receipt entries to a file Prompt the user to enter the Item Name Item Quantity Item Price Display the item name, the quantity, and item price, and the extended price (Item Quantity multiplied by Item Price) after the entry is made Save the item name, quantity, item price, and extended price to a file When you create the file, prompt the user for...
"""stack.py implements stack with a list""" class Stack(object): def __init__(self): #creates an empty stack. O(1) self.top...
"""stack.py implements stack with a list""" class Stack(object): def __init__(self): #creates an empty stack. O(1) self.top = -1 #the index of the top element of the stack. -1: empty stack self.data = [] def push(self, item): # add item to the top of the stack. O(1) self.top += 1 self.data.append(item) def pop(self): # removes and returns the item at the top O(1) self.top -=1 return self.data.pop() def peek(self): # returns the item at the top O(1) return self.data[len(self.data)-1] def isEmpty(self):...
The following Java program is NOT designed using class/object concept. public class demo_Program4_non_OOP_design { public static...
The following Java program is NOT designed using class/object concept. public class demo_Program4_non_OOP_design { public static void main(String[] args) { String bottle1_label="Milk"; float bottle1_volume=250; float bottle1_capacity=500; bottle1_volume=addVolume(bottle1_label, bottle1_volume,bottle1_capacity,200); System.out.println("bottle label: " + bottle1_label + ", volume: " + bottle1_volume + ", capacity: " +bottle1_capacity); String bottle2_label="Water"; float bottle2_volume=100; float bottle2_capacity=250; bottle2_volume=addVolume(bottle2_label, bottle2_volume,bottle2_capacity,500); System.out.println("bottle label: " + bottle2_label + ", volume: " + bottle2_volume + ", capacity: " +bottle2_capacity); } public static float addVolume(String label, float bottleVolume, float capacity, float addVolume)...
For today's lab we will be using the Car Object Class which we built in Lab...
For today's lab we will be using the Car Object Class which we built in Lab 1. I have attached my solution if you would prefer to use my solution instead of your own solution. We will working on remembering how to build sub-classes and user interfaces. So we will be creating new Java files for: An Interface called GreenHouseGasser Requires a method called CO2() which returns how much carbon dioxide the Object produces. Make sure to update Car so...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT