Question

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 description, but not for hours or price; the price field value is calculated as estimated hours times $45.00 ($45.00 / hour) whenever the hours value is set.

Also create the following methods for theJob class:

  • An Equals() method that determines two Jobs are equal if they have the same job number
  • A GetHashCode() method that returns the job number
  • A ToString() method that returns a string containing all job information in the following format:
    Job 111 Smith exterior paint 20 hours @$45.00 per hour. Total price is $900.00 

The JobDemo application declares a few Job objects, sets their values, and demonstrates that all the methods work as expected.

In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System.Globalization; at the top of your program and format the output statements as follows: WriteLine("This is an example: {0}", value.ToString("C", CultureInfo.GetCultureInfo("en-US")));

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

Job.cs :

//namespace
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;
//application namespace
namespace JobDemo
{
class Job //C# class
{
//auto-implemented properties
public int JobNumber { get; set; }
public string Customer { get; set; }
public string Description { get; set; }
private int hours;
private double price;

public int Hours
{
set
{
this.hours = value;//set hours
this.price = this.hours * 45.00;//calculate price
}
}
//constructor
public Job(int jn,string cn,string desc,int h)
{
this.JobNumber = jn;
this.Customer = cn;
this.Description = desc;
this.Hours = h;

}
// override object.Equals
public override bool Equals(Object obj)
{
return (obj is Job) && ((Job)obj).JobNumber == JobNumber;
}

// override object.GetHashCode
public override int GetHashCode()
{
return this.JobNumber;
}
//method to return job details
public override string ToString()
{
return "Job " + this.JobNumber + " " + this.Customer + " " + this.Description + " " + this.hours + " hours @45.00 per hours.Total price is " + this.price.ToString("C", CultureInfo.GetCultureInfo("en-US"));
}
}
}
**************************************************

Program.cs :

//namespace
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//application namesapce
namespace JobDemo
{
class Program //C# class
{
//Main() method
static void Main(string[] args)
{
//creating object of Job class
Job job1 = new Job(111,"Smith", "exterior paint",20);
//creating another object of Job class
Job job2 = new Job(113, "Smith", "exterior paint", 20);
Console.WriteLine(job1.ToString());//print job1
Console.WriteLine(job2.ToString());//print job2
//checking job 1 and job 2
if (job1.Equals(job2))
{
//when both job1 and job 2 are equal
Console.WriteLine("Job 1 and Job 2 are equal");
}
else
{
//when both job1 and job 2 are not equal
Console.WriteLine("Job 1 and Job 2 are not equal");
}
//to hold the string
Console.ReadKey();
}
}
}
==============================================

Screen 1:

Add a comment
Know the answer?
Add Answer to:
C# Create an application named JobDemo that declares and uses Job objects. The Job class holds...
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
  • Create a program named TipCalculation that includes two overloaded methods named DisplayTipInfo. One should accept a...

    Create a program named TipCalculation that includes two overloaded methods named DisplayTipInfo. One should accept a meal price and a tip as doubles (for example, 30.00 and 0.20, where 0.20 represents a 20 percent tip). The other should accept a meal price as a double and a tip amount as an integer (for example, 30.00 and 5, where 5 represents a $5 tip). Each method displays the meal price, the tip as a percentage of the meal price, the tip...

  • 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...

  • 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...

  • 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...

  • In Chapter 5, you wrote a HomeSales application for three salespeople: Danielle, Edward, and Francis. Now,...

    In Chapter 5, you wrote a HomeSales application for three salespeople: Danielle, Edward, and Francis. Now, using the code you wrote in Chapter 5, Programming Exercise 5, modify the program to use arrays to store the salesperson names, allowed initials, and accumulated sales values. In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System.Globalization; at the top of your program and format...

  • In Chapter 5, you wrote a HomeSales application for three salespeople: Danielle, Edward, and Francis. Now,...

    In Chapter 5, you wrote a HomeSales application for three salespeople: Danielle, Edward, and Francis. Now, using the code you wrote in Chapter 5, Programming Exercise 5, modify the program to use arrays to store the salesperson names, allowed initials, and accumulated sales values. In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System.Globalization; at the top of your program and format...

  • Please Help in C#, Let me know if you have any questions. Please make sure the...

    Please Help in C#, Let me know if you have any questions. Please make sure the program passes the checks Checks: Question: My code works, it just this needs to be added there which I don't know what I need to do.    In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System.Globalization; at the top of your program and format the output...

  • Design a class named StockTransaction that holds a stock symbol (typically one to four characters), stock...

    Design a class named StockTransaction that holds a stock symbol (typically one to four characters), stock name, and price per share. Include methods to set and get the values for each data field. Design an application that declares two StockTransaction objects and sets and displays their values. Design an application that declares an array of 15 StockTransaction objects. Prompt the user for data for each object, and then display all the values. Design an application that declares an array of...

  • c# Instructions In Chapter 5, you wrote a HomeSales application for three salespeople: Danielle, Edward, and...

    c# Instructions In Chapter 5, you wrote a HomeSales application for three salespeople: Danielle, Edward, and Francis. Now, using the code you wrote in Chapter 5, Programming Exercise 5, modify the program to use arrays to store the salesperson names, allowed initials, and accumulated sales values. In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System. Globalization; at the top of your...

  • C# Programming : Create a housing application for a property manager. Include a base class named...

    C# Programming : Create a housing application for a property manager. Include a base class named Housing. Include data characteristics such as address and year built. Include a virtual method that returns the total projected rental amount. Define an interface named IUnits that has a method that returns the number of units. The MultiUnit class should implement this interface. Create subclasses for MultiUnit and SingleFamily. SingleFamily should include characteristics such as size in square feet and availability of garage. MultiUnit...

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