in JAVA PLEASE SHOW OUTPUT! PriorityQueueUserDefinedObjectExample (20) Create an Employee class which implements Comparable<Employee> The constructor consists of an employee’s...

80.2K

Verified Solution

Question

Programming

in JAVA PLEASE SHOW OUTPUT!

  1. PriorityQueueUserDefinedObjectExample(20)

Create an Employee class which implementsComparable

The constructor consists of an employee’s first name and anemployee’s salary, both of which are instance variables.

Create accessor and mutator methods for both of thesevariables

Write an equals method that returns true if the salaries areequal with one cent and the names are exactly equal

Write a compareTo method that returns 1 if the salary of thisemployee is greater than the salary of the comparable, -1 if lessthan and 0 if equal.

Create a class called PriorityQueueUserDefinedObjectExample

Create a Scanner to read from the user input.

Create a Scanner and a PrintWriter to read to a file and outputto a different file. (note: You should prompt for the names ofthese files).

The input file has a single name followed by a 5 or 6 figuresalary on each line. (You can use my empsalaries.txt in thehomework for Lesson 7)

Create a PriorityQueue

Read in and add each employee to the queue

Use the remove method as you write the employee and salary tothe output file from lowest salary to highest.

See sample input file empsalaries.txt and output filepriorityemp.txt

//empsalaries

James 1000000.42Oscar 7654321.89Jose 352109.00Daniel 98476.22Juan 452198.70Sean 221133.55Ryan 1854123.77

//priorityemp

  NAME      SALARY Daniel    $ 98476.22  Sean    $221133.55  Jose    $352109.00  Juan    $452198.70  James    $1000000.42  Ryan    $1854123.77  Oscar    $7654321.89

Answer & Explanation Solved by verified expert
3.8 Ratings (594 Votes)
SOLUTIONI have solve the problem in Java code with comments and screenshotfor easy understanding CODEEmployeejavapublic class Employee implements Comparable Instance variables private String firstName private double salary Constructor param    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students