Question

Using C#: Create an application class named BillDemo that instantiates objects of two classes named Bill...

Using C#: Create an application class named BillDemo that instantiates objects of two classes named Bill and OverdueBill, and that demonstrates all their methods. The Bill class includes auto-implemented properties for the name of the company or person to whom the bill is owed and for the amount due. Also, include a ToString() method and returns a string that contains the name of the class (using GetType()) and the Bill’s data fields values. Create a child class named OverdueBill that includes an auto-implemented property that holds the number of days the bill is overdue.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Here a new Console Application in C# is created using Visual Studio 2017 with name "BillDemoApplication".This application contains below class.

BillDemo.cs :

//namespace
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//application namespace
namespace BillDemoApplication
{
class BillDemo //C# class
{
//entry point of application Main method
static void Main(string[] args)
{
//creating object of Bill class
Bill bill = new Bill();
//creating object of OverdueBill class
OverdueBill overdueBill = new OverdueBill();
//asking user to enter name
Console.Write("Enter Name : ");
bill.name = Console.ReadLine();//reading name
//asking user to enter amount due
Console.Write("Enter amount due : ");
bill.amountDue = double.Parse(Console.ReadLine());//reading name
//asking user to enter number of days bill is overdue
Console.Write("Enter number of days bill is overdue : ");
overdueBill.numberOfDays = int.Parse(Console.ReadLine());//reading number of days
//print details
Console.WriteLine(bill.ToString()+Environment.NewLine+overdueBill.ToString());
//to hold the screen
Console.ReadKey();
}
}
//class Bill
class Bill
{
//auto-implemented properties
public string name { get; set; }
public double amountDue { get; set; }
//ToString() method
public override string ToString()
{
//return name of the class with name and amount due
return "Class Name : " + GetType() + "\nName : " + name + "\nAmount Due : " + amountDue;
}
}
//class OverdueBill
class OverdueBill : Bill
{
//auto-implemented properties
public int numberOfDays { get; set; }
//ToString() method
public override string ToString()
{
//return Number of Days bill overdue
return "Number of Days bill overdue : " + numberOfDays;
}
}
}

======================================================

Output : Run application using F5 and will get the screen as shown below

Screen 1 :BillDemo.cs

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
Using C#: Create an application class named BillDemo that instantiates objects of two classes named Bill...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using C# Create an application class named LetterDemo that instantiates objects of two classes named Letter...

    Using C# Create an application class named LetterDemo that instantiates objects of two classes named Letter and CertifiedLetter and that demonstrates all their methods. The classes are used by a company to keep track of letters they mail to clients. The Letter class includes auto-implemented properties for the Name of the recipient and the Date mailed (stored as strings). Next, include a ToString() method that overrides the Object class’s ToString() method and returns a string that contains the name of...

  • C# Create an application named JobDemo that declares and uses Job objects. The Job class holds...

    C# Create an application named JobDemo that declares and uses Job objects. The Job class holds job information for a home repair service. The class has five properties that include: JobNumber - The job number Customer - The customer name Description - The job description Hours - The estimated hours price - The price for the job Create a constructor that requires parameters for all the data except price. Include auto-implemented properties for the job number, customer name, and job...

  • Include outputs. Write a C# console application named Tape that includes fields for length and width...

    Include outputs. Write a C# console application named Tape that includes fields for length and width in inches and properties for each field. Also include a ToString() method that returns a string constructed from the return value of the object's GetType() method and the values of the length and width fields. Derive two subclasses - VideoCassetteTape and AdhesiveTape. The VideoCassetteTape class includes an integer field to hold playing time in minutes - a value from 1 to 180 - and...

  • In the Book class you created in Exercise 4a, overload the Object class Equals() method to...

    In the Book class you created in Exercise 4a, overload the Object class Equals() method to consider two Books equal if they have the same ISBN. Create a program that declares three Books; two should have the same ISBN and one should have a different one. Demonstrate that the Equals() method works correctly to compare the Books. Save the program as BookDemo2. c. Write an application that declares two Book objects and uses an extension method named DisplayTitleAndAuthor() with each....

  • Using C#: Create an application named TestClassifiedAd that instantiates and displays a ClassifiedAd object. A ClassifiedAd...

    Using C#: Create an application named TestClassifiedAd that instantiates and displays a ClassifiedAd object. A ClassifiedAd has fields for a category (for example, "Used Cars"), a number of words, and a price. Include properties that contain get and set accessors for the category and number of words, but only a get accessor for the price. The price is calculated at nine cents per word.

  • Create a program named TilingDemo that instantiates an array of 10 Room objects and demonstrates its...

    Create a program named TilingDemo that instantiates an array of 10 Room objects and demonstrates its methods. The Room constructor requires parameters for length and width fields; use a variety of values when constructing the objects. The Room class also contains a field for floor area of the Room and number of boxes of tile needed to tile the room. Both of these values are computed by calling private methods. A room requires one box of tile for every 12...

  • Inheritance and Polymorphism (use Pet.java) You are given a class named Pet.java.   Create two child classes...

    Inheritance and Polymorphism (use Pet.java) You are given a class named Pet.java.   Create two child classes named Cat.java and Dog.java. Cat.java should add attributes for color and breed. Dog.java should add attributes for breed and size (use String for small, medium, large). Add appropriate constructors, getter/setter methods and toString() methods.   In a separate file named PetDriver.java, create a main. In the main, create an ArrayList of Pet. Add an instance of Cat and an instance of Dog to the ArrayList....

  • C++ Create an application named CarDemo that declares at least two Car objects and demonstrates how...

    C++ Create an application named CarDemo that declares at least two Car objects and demonstrates how they can be incremented using an overloaded ++ operator. Create a Car class that contains the following properties: Model - The car model (as a string) Mpg The car's miles per gallon (as a double) Include two overloaded constructors. One accepts parameters for the model and miles per gallon; the other accepts a model and sets the miles per gallon to 20. Overload a...

  •     Create a C# program named PaintingDemo that instantiates an array of eight Room objects and...

        Create a C# program named PaintingDemo that instantiates an array of eight Room objects and demonstrates the Room methods. The Room constructor requires parameters for length, width, and height fields; use a variety of values when constructing the objects. The Room class also contains a field for wall area of the Room and number of gallons of paint needed to paint the room. Both of these values are computed by calling private methods. Include read-only properties to get a...

  • C+ Create an application named CarDemo that declares at least two Car objects and demonstrates how...

    C+ Create an application named CarDemo that declares at least two Car objects and demonstrates how they can be incremented using an overloaded ++ operator. Create a Car class that contains the following properties: Model - The car model (as a string) Mpg The car's miles per gallon (as a double) Include two overloaded constructors. One accepts parameters for the model and miles per gallon; the other accepts a model and sets the miles per gallon to 20. Overload a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT