Question: What I need: Harold has realized that his method for computing the fee for combined jobs is not fair. For example, consider the following: His

What I need:

Harold has realized that his method for computing the fee for combined jobs is not fair. For example, consider the following:

  • His fee for painting a house is $100 per hour. If a job takes 10 hours, he earns $1000.
  • His fee for dog walking is $10 per hour. If a job takes 1 hour, he earns $10.
  • If he combines the two jobs and works a total of 11 hours, he earns only the average rate of $55 per hour, or $605.

Instructions

Devise an improved, weighted method for calculating Harolds fees for combined Jobs and include it in the overloaded operator+() method. Write a program named DemoJobs2 that demonstrates all the methods in the class work correctly.

What I have:

using System;

public class AddJobs

{

private double totalFee;

public AddJobs(double totalFee)

{

TotalFee = totalFee;

}

public static void Main()

{

Job job1 = new Job("washing windows", 5.00, 25.00);

Job job2 = new Job("walking a dog", 3.00, 11.00);

Job job3;

job3 = job1 + job2;

Console.WriteLine("The first job's description: {0} Total time needed to complete the job: {1} hours Hourly fee: {2} per hour", job1.Description, job1.Time, job1.Rate.ToString("C"));

TotalPay(job1);

Console.WriteLine("The second job's description: {0} Total time needed to complete the job: {1} hours Hourly fee: {2} per hour", job2.Description, job2.Time, job2.Rate.ToString("C"));

TotalPay(job2);

Console.WriteLine("The third job's description: {0} Total time needed to complete the job: {1} hours Hourly fee: {2} per hour", job3.Description, job3.Time, job3.Rate.ToString("C"));

TotalPay(job3);

}

public static void TotalPay(Job method)

{

double totalFee = Job.rate * Job.time;

Console.WriteLine("The total fee is: {0}", TotalFee.ToString("C"));

}

}

class Job

{

public Job(string description, double time, double rate)

{

Description = description;

Time = time;

Rate = rate;

}

public static Job operator+(Job first, Job second)

{

string newDescription = first.Description + " and " + second.Description;

double newTime = first.Time + second.Time;

double newRate = (first.Rate + second.Rate) / 2;

double newTotalFee = newRate * newTime;

return(new Job(newDescription, newTime, newRate));

}

public string Description {get; set;}

public double Time {get; set;}

public double Rate {get; set;}

}

Error I get:

Compilation failed: 1 error(s), 0 warnings DemoJobs2.cs(43,20): error CS0051: Inconsistent accessibility: parameter type `Job' is less accessible than method `AddJobs.TotalPay(Job)' DemoJobs2.cs(55,7): (Location of the symbol related to previous error)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!