Make any necessary modifications to the RushJob class so that it can be sorted by job number. Modify the JobDemo3 application so the displayed orders have been sorted. using System; using static System.Console; using System.Globalization; class JobDemo4 {    static void Main()    {       RushJob[] jobs = new RushJob[5];       int x, y;       double grandTotal = 0;       bool goodNum;       for(x = 0 ; x < jobs.Length; ++x)       {          jobs[x] = new RushJob();          Write("Enter job number ");          jobs[x].JobNumber = Convert.ToInt32(ReadLine());          goodNum = true;          for(y = 0; y < x; ++y)          {             if(jobs[x].Equals(jobs[y]))                goodNum = false;          }          while(!goodNum)          {              Write("Sorry, the job number " +                 jobs[x].JobNumber + " is a duplicate. " +                 "\nPlease reenter ");              jobs[x].JobNumber = Convert.ToInt32(ReadLine());              goodNum = true;              for(y = 0; y < x; ++y)              {                 if(jobs[x].Equals(jobs[y]))                    goodNum = false;              }          }          Write("Enter customer name ");          jobs[x].Customer = ReadLine();          Write("Enter description ");          jobs[x].Description = ReadLine();          Write("Enter estimated hours ");          jobs[x].Hours = Convert.ToDouble(ReadLine());       }       WriteLine("\nSummary:\n");       for(x = 0; x < jobs.Length; ++x)       {          WriteLine(jobs[x].ToString());          grandTotal += jobs[x].Price;       }       WriteLine("\nTotal for all jobs is " + grandTotal.ToString("C", CultureInfo.GetCultureInfo("en-US")));    }   }    class Job {    protected double hours;    protected double price;    public const double RATE = 45.00;    public Job(int num, string cust, string desc, double hrs)    {       JobNumber = num;       Customer = cust;       Description = desc;       Hours = hrs;    }    public int JobNumber {get; set;}    public string Customer {get; set;}    public string Description {get; set;}    public double Hours    {       get       {          return hours;       }       set       {          hours = value;          price = hours * RATE;       }    }    public double Price    {        get        {           return price;        }   }    public override string ToString()    {       return(GetType() + " " + JobNumber + " " + Customer + " " +          Description + " " + Hours + " hours @" + RATE.ToString("C") +          " per hour. Total price is " + Price.ToString("C", CultureInfo.GetCultureInfo("en-US")));    }    public override bool Equals(Object e)    {       bool equal;       Job temp = (Job)e;       if(JobNumber == temp.JobNumber)         equal = true;       else         equal = false;       return equal;    }    public override int GetHashCode()    {       return JobNumber;    } } class RushJob : Job {    public const double PREMIUM = 150.00;    public RushJob() :base(0, "", "", 0)    {    }     public override string ToString()    {       return(GetType() + " " + JobNumber + " " + Customer + " " +          Description + " " + Hours + " hours @" + RATE.ToString("C") +          " per hour. Rush job adds " + PREMIUM +          " premium. Total price is " + Price.ToString("C", CultureInfo.GetCultureInfo("en-US")));    }    public new double Hours    {       get       {          return hours;       }       set       {          hours = value;          price = hours * RATE + PREMIUM;       }    } }

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter7: File Handling And Applications
Section: Chapter Questions
Problem 7PE
icon
Related questions
Question

Make any necessary modifications to the RushJob class so that it can be sorted by job number. Modify the JobDemo3 application so the displayed orders have been sorted.

using System;
using static System.Console;
using System.Globalization;

class JobDemo4
{
   static void Main()
   {
      RushJob[] jobs = new RushJob[5];
      int x, y;
      double grandTotal = 0;
      bool goodNum;
      for(x = 0 ; x < jobs.Length; ++x)
      {
         jobs[x] = new RushJob();
         Write("Enter job number ");
         jobs[x].JobNumber = Convert.ToInt32(ReadLine());
         goodNum = true;
         for(y = 0; y < x; ++y)
         {
            if(jobs[x].Equals(jobs[y]))
               goodNum = false;
         }
         while(!goodNum)
         {
             Write("Sorry, the job number " +
                jobs[x].JobNumber + " is a duplicate. " +
                "\nPlease reenter ");
             jobs[x].JobNumber = Convert.ToInt32(ReadLine());
             goodNum = true;
             for(y = 0; y < x; ++y)
             {
                if(jobs[x].Equals(jobs[y]))
                   goodNum = false;
             }
         }
         Write("Enter customer name ");
         jobs[x].Customer = ReadLine();
         Write("Enter description ");
         jobs[x].Description = ReadLine();
         Write("Enter estimated hours ");
         jobs[x].Hours = Convert.ToDouble(ReadLine());
      }
      WriteLine("\nSummary:\n");
      for(x = 0; x < jobs.Length; ++x)
      {
         WriteLine(jobs[x].ToString());
         grandTotal += jobs[x].Price;
      }
      WriteLine("\nTotal for all jobs is " + grandTotal.ToString("C", CultureInfo.GetCultureInfo("en-US")));
   }
 
}   
class Job
{
   protected double hours;
   protected double price;
   public const double RATE = 45.00;
   public Job(int num, string cust, string desc, double hrs)
   {
      JobNumber = num;
      Customer = cust;
      Description = desc;
      Hours = hrs;
   }
   public int JobNumber {get; set;}
   public string Customer {get; set;}
   public string Description {get; set;}
   public double Hours
   {
      get
      {
         return hours;
      }
      set
      {
         hours = value;
         price = hours * RATE;
      }
   }
   public double Price
   {
       get
       {
          return price;
       }
  }
   public override string ToString()
   {
      return(GetType() + " " + JobNumber + " " + Customer + " " +
         Description + " " + Hours + " hours @" + RATE.ToString("C") +
         " per hour. Total price is " + Price.ToString("C", CultureInfo.GetCultureInfo("en-US")));
   }
   public override bool Equals(Object e)
   {
      bool equal;
      Job temp = (Job)e;
      if(JobNumber == temp.JobNumber)
        equal = true;
      else
        equal = false;
      return equal;
   }
   public override int GetHashCode()
   {
      return JobNumber;
   }
}

class RushJob : Job
{
   public const double PREMIUM = 150.00;
   public RushJob() :base(0, "", "", 0)
   {
   } 
   public override string ToString()
   {
      return(GetType() + " " + JobNumber + " " + Customer + " " +
         Description + " " + Hours + " hours @" + RATE.ToString("C") +
         " per hour. Rush job adds " + PREMIUM +
         " premium. Total price is " + Price.ToString("C", CultureInfo.GetCultureInfo("en-US")));
   }
   public new double Hours
   {
      get
      {
         return hours;
      }
      set
      {
         hours = value;
         price = hours * RATE + PREMIUM;
      }
   }
}
An example of the program is shown below:
Enter job number 22
Enter customer name Joe
Enter description Powerwashing
Enter estimated hours 4
Enter job number 6
Enter customer name Joey
Enter description Painting
Enter estimated hours 8
Enter job number 12
Enter customer name Joseph
Enter description Carpet cleaning
Enter estimated hours 5
Enter job number 9
Enter customer name Josefine
Enter description Moving
Enter estimated hours 12
Enter job number 21
Enter customer name Josefina
Enter description Dog walking
Enter estimated hours 2
Summary:
RushJob 6 Joey Painting 8 hours @$45.00 per hc
RushJob 9 Josefine Moving 12 hours @$45.00 per
Rush Job 12 Joseph Carpet cleaning 5 hours @$45
RushJob 21 Josefina Dog walking 2 hours @$45.0
RushJob 22 Joe Powerwashing 4 hours @$45.00 pe
Transcribed Image Text:An example of the program is shown below: Enter job number 22 Enter customer name Joe Enter description Powerwashing Enter estimated hours 4 Enter job number 6 Enter customer name Joey Enter description Painting Enter estimated hours 8 Enter job number 12 Enter customer name Joseph Enter description Carpet cleaning Enter estimated hours 5 Enter job number 9 Enter customer name Josefine Enter description Moving Enter estimated hours 12 Enter job number 21 Enter customer name Josefina Enter description Dog walking Enter estimated hours 2 Summary: RushJob 6 Joey Painting 8 hours @$45.00 per hc RushJob 9 Josefine Moving 12 hours @$45.00 per Rush Job 12 Joseph Carpet cleaning 5 hours @$45 RushJob 21 Josefina Dog walking 2 hours @$45.0 RushJob 22 Joe Powerwashing 4 hours @$45.00 pe
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Array
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
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning