Question: Need help with JAVA assignment! Please! Exercise 2B [15%] Add three variables to the Employee class: - a private String called name that will contain

Need help with JAVA assignment! Please!

Need help with JAVA assignment! Please! Exercise 2B [15\%] Add three variables

Exercise 2B [15\%] Add three variables to the Employee class: - a private String called name that will contain the name of the employee - a private double called monthlySalary that will contain the monthly salary Next add the constructor. Set name and monthlySalary using parameters. Finally add three methods: - a public method called getName with no parameters that returns the name variable - a public method called getMonthlySalary with no parameters that returns the monthlySalary variable - a public method called getAnnualSalary with no parameters that returns the annual salary of the employee formatted to have only two decimal places (e.g. 10.3832 will be returned as 10.38) Exercise 2C [10\%] Add code to Programmer so that the class inherits from Employee. Add one variable to the Programmer class: - a private String called language that will contain the programming language this programmer is skilled in Next add a constructor to Programmer that also receives a String to set name, a double to set monthly salary and a String to set the language. Please look up how to call the constructor of the parent class. Finally add one method: - a public method called getLanguage that returns the programming language Exercise 2D [20\%] Add code to SeniorProgrammer so that the class inherits from Programmer. Add a class variable that is of type double, is private, is called bonus and will be used to store the annual bonus of the senior programmer. Next add a constructor to SeniorProgrammer that also receives a String to set name, a double to set monthly salary, a String to set the language and another double to set the bonus. Finally add one public method called getAnnualSalary that overrides the method belonging to Employee so that it takes the bonus into account. Make sure that this method also returns the salary with only two decimal places even if the bonus is specified with more. The return value of this method should also be formatted to have only two decimal places. To avoid code duplication place the code for formatting in a separate method (which should belong to Employee) that you can use in both the getAnnualSalary methods. Exercise 2E [5\%] In the main method belonging to MainExercise2 implement the following to test your code: - Create a programmer called Winston with a monthly salary of 2208.51 specialised on Java - Print name, language and annual salary of the programmer to the command line separated by spaces - Create a senior programmer called Anna with a monthly salary of 3211.22 specialised on Python and a bonus of 5300.89 - Print name, language and annual salary of the senior programmer to the command line separated by spaces This could look like the following: Winston Java 26502.12 Anna Python 43835.53

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!