Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

by basic java Exercise 1: (1 point) Project Name Instruction Remark : _LAB04_LAB04_TaxPayment : Download and complete an abstract class Employee from the following UML.

by basic java

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Exercise 1: (1 point) Project Name Instruction Remark : _LAB04_LAB04_TaxPayment : Download and complete an abstract class Employee from the following UML. : + denotes public modifier. Employee Description name: String position: String Name of Employee Position of Employee Employee(name: String, position: String) A 2-arguments constructor calculateMonthlyIncome ( ): double An abstract method to calculate and return the monthly income of an employee printworkPlace(): void An abstract method to print Workplace for its subclass printInfo(): void Print info of an Employee in the following format name is a position calculateTaxRate(salary: double): double Calculate and return the tax rate of Employee from the input salary in the following conditions. Less than or equal to 200000, the tax rate is 0.0 Less than or equal to 400000, the tax rate is 0.05 Less than or equal to 600000, the tax rate is 0.1 Less than or equal to 800000, the tax rate is 0.15 Otherwise, the tax rate is 0.2 An abstract method to calculate and return the monthly income of an employee An abstract method to print Workplace for its subclass Lim Exercise 2: (1 point) Project Name Instruction Remark : _LAB04_LAB04_TaxPayment : Download and complete an interface Taxpayer from the following UML. : + denotes public modifier. : interface>> Taxpayer Description + calculateYearlyIncome ( ): double An abstract method for calculating yearly income + calculateTax( ): double An abstract method for calculating Tax + paytax(): void An abstract method for paying Tax this Exercise 3: (3 points) Project Name Instruction Remark : LAB04_LAB04_Tax Payment : Download and complete a class FullTime as a subclass of Employee and Taxpayer. : + denotes public modifier. > Taxpayer Employee FullTime Description workplace: String salary: double workplace of Employee salary of Employee A 4- arguments constructor FullTime(name: String, position: String, workplace: String, salary: double) void printworkPlace( ) Overridden method to print workplace of an Employee in the following format: Work at workPlace calculateMonthlyIncome ( ): double Overridden method to calculate and return salary +calculateYearlyIncome ( ): double Overridden method to calculate and return 12*salary +calculateTax( ): double Overridden method to calculate and return tax value which is the tax rate * Yearly Income Remark: use the calculateTaxRate() method of the employee to obtain the tax rate + paytax( ): void Overridden method to print the output in Pay tax $ Calculated Tax + printInfo( ): void Overwritten method to print the FullTime in the following format name is a position Work at workPlace Yearly income is calculatedYearlyIncome Pay tax $CalculatedTax Exercise 4: (3 points) Project Name Instruction Taxpayer. Remark : _LAB04_LAB04_TaxPayment : Download and complete a class PartTime as a subclass of Employee and : + denotes public modifier. Part Time workplace: String numHrPerWeek: double hourlyRate: double Description workplace of Employee a number of working hours per week an hourly rate A 4-arguments constructor that initialize the properties of the superclass and properties of Part Time PartTime(name: String, position: String, workplace: String, numHrPerWeek: double, hourlyRate: double) printworkPlace(): void Overridden method to print workplace of a PartTime in the following format: Work at calculateMonthlyIncome(): double Overridden method to calculate and return numHrPer Week*hourlyRate*4 +calculateYearlyIncome(): double Overridden method to calculate and return Yearly Income which is 12 * monthly income +calculateTax(): double Overridden method to calculate and return tax value which is the tax rate * Yearly Income Remark: use the method calculate Tax Rate() of the employee to obtain the tax rate +paytax(): void Overridden method to print the output in the format of Pay tax printInfo(): void Overwritten method to print the FullTime in the following format: Name is a position Work at workplace Yearly income is XXXXX Pay tax $XXXXX Exercise 5: (2 points) Project Name Instruction : _LAB04_LAB04_Tax Payment : Download and complete a class TaxPayment Test with a main method. In main, write the code that complete the following task. : + denotes public modifier. Remark a) Download the class TaxPaymentTest with the main method and run the program. If you write the programs Taxpayer, Employee, FullTime and PartTime correctly, the outputs should be as follows. Erika Parker is a secretary Work at InfoTech Yearly income is 390000.0 Pay tax $19500.0 Brian Lee is a driver Work at InfoTech Yearly income is 72000.0 Pay tax $0.0 James Knein is a technician Work at InfoTech Yearly income is 426000.0 Pay tax $42600.0 Anne Lin is an accountant Work at InfoTech Yearly income is 216000.0 Pay tax $10800.0 Jamie Fox is a manager Work at InfoTech Yearly income is 687600.0 Pay tax $103140.0 b) Uncomment the codes in this part b), there are errors in these statements. Can you explain the reason? Answer this question to the TA to get a pass on this problem. Without changing the class-types declaration of the following variables: employee01_FullTime, employee02_PartTime, and employee05_TaxPayer, what do you need to do to be able to call payTax() of ft, pt, and t1. (Hint: casting) The outputs should be as follows. Pay tax $19500.0 Pay tax $0.0 Pay tax $103140.0 e ge A Employee.java X O FullTime.java PartTime.java TaxPayment Test.java Users > pauruetai > Downloads > O Employee.java > Re Employee > printInfo() 1 [/Define Employee to be an abstract class 2 public class Employee { 3 String name; 4 String position; 5 6 public Employee(String name, String position) { 7 // assign the input arguments to their corresponding properties 8 9 } 10 11 // define all abstract methods according to UML 12 13 protected void printInfo() { 14 // Print info of an Employee in the format of [name] is a [position] 15 16 17 18 // This method is provided. No need to add anything. 19 public double calculateTaxRate( double salary) { 20 if (??) // conditions 21 return ??; // return tax rate 22 else if (??) // conditions 23 return ?? in return tax rate 24 else if (??) // conditions 25 return ??; //return tax rate 26 else if (??) // conditions 27 return??ill return tax rate 28 else 29 return ??; //return tax rate 30 31 32 } 1 2 Employee.java Full Time.java x PartTime.java TaxPaymentTest.java Users > pauruetai > Downloads > O FullTime.java > Po Full Time K/Define class full time to be a subclass of Employee and Taxpayer Oblic class FullTime { double salary; 4 String workPlace; 5 FullTime (String name, String position, String workplace, double salary) { // Use super to initialize name and position 3 ge 6 7 8 // assign the input arguments to their corresponding perperties 9 10 11 } // Write by yourself all overriden methods from its parents 12 13 14 15 16 17 18 protected void printInfo() { /* * print the Fulltime in the following format name is a position Work at * workPlace Yearly income is XXXXX Pay tax $XXXXX */ System.out.println(". 19 20 21 22 23 24 } } Employee.java O FullTime.java O Part Time.java x TaxPayment Test.java Users > pauruetai > Downloads > O PartTime.java > Pig PartTime 1 /Define PartTime to be the subclass of Employee and TaxPayer 2 blic class PartTime extends Employee implements TaxPayer { 3 String workplace; int numHrPerweek; 5 double hourlyRate; 6 PartTime(String name String position, String workPlacemint numHrPerWeekendouble hourlyRate) { 8 // Use super to initialize name and position 4 go 7 9 10 // assign inputs workplace, numHrPerWeek, and hourlyRate to their corresponding // properies 11 12 A } 13 14 // define all overridden methods from the abtract parents 15 16 17 18 19 20 21 22 protected void printInfo() { /* * Print PartTime in the following format name is a position Work at work Place * Yearly income is XXXXX Pay tax $XXXXX */ 23 System.out.println("- } 24 25 } u Employee.java Full Time.java o PartTime.java TaxPayment Test.java X o 6 A Users > pauruetai > Downloads > TaxPaymentTest.java > Peg TaxPayment Testing 1 package student; 2 3 public class TaxPaymentTesting { Run Debug 4 public static void main(String[] args) { 5 // Ex5 Part A) Fulltime employee01_FullTime = new FullTime("Erika Parker", "secretary", "InfoTech", 32500.00); 7 PartTime employee02_PartTime = new PartTime("Brian Lee", "driver", "InfoTech", 15, 100); 8 Employee employee03 = new FullTime("James Knein", "tecnician", "InfoTech", 35500.00); 9 Employee employee04 = new PartTime("Anne Lin", "accountant", "InfoTech", 30, 150); 10 TaxPayer employee05_Taxpayer = new FullTime("Jamie Fox", "Manager", "InfoTech", 57300.00); 11 12 employee01_FullTime.printInfo(); //Erika Parker 13 employee02_PartTime.printInfo(); //Brian Lee 14 employee03.printInfo(); //James Knein 15 employee04.printInfo(); //Anne Lin 16 ??, employee05_TaxPayer_??-printInfo(); //Jamie Fox, try casting 17 18 19 // Ex5 Part b) 20 // Without changing the class-types declaration of the following variables: 21 // what do you need to do to be able to call paytax() of ft, pt, and t1. (Hint: casting) 22 /* 23 * employee01_FullTime: paytax(); 24 * employee02_PartTime.paytax(); 25 * employee05_TaxPayer.paytax(); 26 27 */ 28 29 } 30 Taxpayer.java x Employee.java Full Time.java PartTime.java Users > pauruetai > Downloads > TaxPayer.java 1 \/define TaxPayer to be an interface 2 3 Taxpayer [ 4 I/add, abstract methods to this interface 5 6 3 Exercise 1: (1 point) Project Name Instruction Remark : _LAB04_LAB04_TaxPayment : Download and complete an abstract class Employee from the following UML. : + denotes public modifier. Employee Description name: String position: String Name of Employee Position of Employee Employee(name: String, position: String) A 2-arguments constructor calculateMonthlyIncome ( ): double An abstract method to calculate and return the monthly income of an employee printworkPlace(): void An abstract method to print Workplace for its subclass printInfo(): void Print info of an Employee in the following format name is a position calculateTaxRate(salary: double): double Calculate and return the tax rate of Employee from the input salary in the following conditions. Less than or equal to 200000, the tax rate is 0.0 Less than or equal to 400000, the tax rate is 0.05 Less than or equal to 600000, the tax rate is 0.1 Less than or equal to 800000, the tax rate is 0.15 Otherwise, the tax rate is 0.2 An abstract method to calculate and return the monthly income of an employee An abstract method to print Workplace for its subclass Lim Exercise 2: (1 point) Project Name Instruction Remark : _LAB04_LAB04_TaxPayment : Download and complete an interface Taxpayer from the following UML. : + denotes public modifier. : interface>> Taxpayer Description + calculateYearlyIncome ( ): double An abstract method for calculating yearly income + calculateTax( ): double An abstract method for calculating Tax + paytax(): void An abstract method for paying Tax this Exercise 3: (3 points) Project Name Instruction Remark : LAB04_LAB04_Tax Payment : Download and complete a class FullTime as a subclass of Employee and Taxpayer. : + denotes public modifier. > Taxpayer Employee FullTime Description workplace: String salary: double workplace of Employee salary of Employee A 4- arguments constructor FullTime(name: String, position: String, workplace: String, salary: double) void printworkPlace( ) Overridden method to print workplace of an Employee in the following format: Work at workPlace calculateMonthlyIncome ( ): double Overridden method to calculate and return salary +calculateYearlyIncome ( ): double Overridden method to calculate and return 12*salary +calculateTax( ): double Overridden method to calculate and return tax value which is the tax rate * Yearly Income Remark: use the calculateTaxRate() method of the employee to obtain the tax rate + paytax( ): void Overridden method to print the output in Pay tax $ Calculated Tax + printInfo( ): void Overwritten method to print the FullTime in the following format name is a position Work at workPlace Yearly income is calculatedYearlyIncome Pay tax $CalculatedTax Exercise 4: (3 points) Project Name Instruction Taxpayer. Remark : _LAB04_LAB04_TaxPayment : Download and complete a class PartTime as a subclass of Employee and : + denotes public modifier. Part Time workplace: String numHrPerWeek: double hourlyRate: double Description workplace of Employee a number of working hours per week an hourly rate A 4-arguments constructor that initialize the properties of the superclass and properties of Part Time PartTime(name: String, position: String, workplace: String, numHrPerWeek: double, hourlyRate: double) printworkPlace(): void Overridden method to print workplace of a PartTime in the following format: Work at calculateMonthlyIncome(): double Overridden method to calculate and return numHrPer Week*hourlyRate*4 +calculateYearlyIncome(): double Overridden method to calculate and return Yearly Income which is 12 * monthly income +calculateTax(): double Overridden method to calculate and return tax value which is the tax rate * Yearly Income Remark: use the method calculate Tax Rate() of the employee to obtain the tax rate +paytax(): void Overridden method to print the output in the format of Pay tax printInfo(): void Overwritten method to print the FullTime in the following format: Name is a position Work at workplace Yearly income is XXXXX Pay tax $XXXXX Exercise 5: (2 points) Project Name Instruction : _LAB04_LAB04_Tax Payment : Download and complete a class TaxPayment Test with a main method. In main, write the code that complete the following task. : + denotes public modifier. Remark a) Download the class TaxPaymentTest with the main method and run the program. If you write the programs Taxpayer, Employee, FullTime and PartTime correctly, the outputs should be as follows. Erika Parker is a secretary Work at InfoTech Yearly income is 390000.0 Pay tax $19500.0 Brian Lee is a driver Work at InfoTech Yearly income is 72000.0 Pay tax $0.0 James Knein is a technician Work at InfoTech Yearly income is 426000.0 Pay tax $42600.0 Anne Lin is an accountant Work at InfoTech Yearly income is 216000.0 Pay tax $10800.0 Jamie Fox is a manager Work at InfoTech Yearly income is 687600.0 Pay tax $103140.0 b) Uncomment the codes in this part b), there are errors in these statements. Can you explain the reason? Answer this question to the TA to get a pass on this problem. Without changing the class-types declaration of the following variables: employee01_FullTime, employee02_PartTime, and employee05_TaxPayer, what do you need to do to be able to call payTax() of ft, pt, and t1. (Hint: casting) The outputs should be as follows. Pay tax $19500.0 Pay tax $0.0 Pay tax $103140.0 e ge A Employee.java X O FullTime.java PartTime.java TaxPayment Test.java Users > pauruetai > Downloads > O Employee.java > Re Employee > printInfo() 1 [/Define Employee to be an abstract class 2 public class Employee { 3 String name; 4 String position; 5 6 public Employee(String name, String position) { 7 // assign the input arguments to their corresponding properties 8 9 } 10 11 // define all abstract methods according to UML 12 13 protected void printInfo() { 14 // Print info of an Employee in the format of [name] is a [position] 15 16 17 18 // This method is provided. No need to add anything. 19 public double calculateTaxRate( double salary) { 20 if (??) // conditions 21 return ??; // return tax rate 22 else if (??) // conditions 23 return ?? in return tax rate 24 else if (??) // conditions 25 return ??; //return tax rate 26 else if (??) // conditions 27 return??ill return tax rate 28 else 29 return ??; //return tax rate 30 31 32 } 1 2 Employee.java Full Time.java x PartTime.java TaxPaymentTest.java Users > pauruetai > Downloads > O FullTime.java > Po Full Time K/Define class full time to be a subclass of Employee and Taxpayer Oblic class FullTime { double salary; 4 String workPlace; 5 FullTime (String name, String position, String workplace, double salary) { // Use super to initialize name and position 3 ge 6 7 8 // assign the input arguments to their corresponding perperties 9 10 11 } // Write by yourself all overriden methods from its parents 12 13 14 15 16 17 18 protected void printInfo() { /* * print the Fulltime in the following format name is a position Work at * workPlace Yearly income is XXXXX Pay tax $XXXXX */ System.out.println(". 19 20 21 22 23 24 } } Employee.java O FullTime.java O Part Time.java x TaxPayment Test.java Users > pauruetai > Downloads > O PartTime.java > Pig PartTime 1 /Define PartTime to be the subclass of Employee and TaxPayer 2 blic class PartTime extends Employee implements TaxPayer { 3 String workplace; int numHrPerweek; 5 double hourlyRate; 6 PartTime(String name String position, String workPlacemint numHrPerWeekendouble hourlyRate) { 8 // Use super to initialize name and position 4 go 7 9 10 // assign inputs workplace, numHrPerWeek, and hourlyRate to their corresponding // properies 11 12 A } 13 14 // define all overridden methods from the abtract parents 15 16 17 18 19 20 21 22 protected void printInfo() { /* * Print PartTime in the following format name is a position Work at work Place * Yearly income is XXXXX Pay tax $XXXXX */ 23 System.out.println("- } 24 25 } u Employee.java Full Time.java o PartTime.java TaxPayment Test.java X o 6 A Users > pauruetai > Downloads > TaxPaymentTest.java > Peg TaxPayment Testing 1 package student; 2 3 public class TaxPaymentTesting { Run Debug 4 public static void main(String[] args) { 5 // Ex5 Part A) Fulltime employee01_FullTime = new FullTime("Erika Parker", "secretary", "InfoTech", 32500.00); 7 PartTime employee02_PartTime = new PartTime("Brian Lee", "driver", "InfoTech", 15, 100); 8 Employee employee03 = new FullTime("James Knein", "tecnician", "InfoTech", 35500.00); 9 Employee employee04 = new PartTime("Anne Lin", "accountant", "InfoTech", 30, 150); 10 TaxPayer employee05_Taxpayer = new FullTime("Jamie Fox", "Manager", "InfoTech", 57300.00); 11 12 employee01_FullTime.printInfo(); //Erika Parker 13 employee02_PartTime.printInfo(); //Brian Lee 14 employee03.printInfo(); //James Knein 15 employee04.printInfo(); //Anne Lin 16 ??, employee05_TaxPayer_??-printInfo(); //Jamie Fox, try casting 17 18 19 // Ex5 Part b) 20 // Without changing the class-types declaration of the following variables: 21 // what do you need to do to be able to call paytax() of ft, pt, and t1. (Hint: casting) 22 /* 23 * employee01_FullTime: paytax(); 24 * employee02_PartTime.paytax(); 25 * employee05_TaxPayer.paytax(); 26 27 */ 28 29 } 30 Taxpayer.java x Employee.java Full Time.java PartTime.java Users > pauruetai > Downloads > TaxPayer.java 1 \/define TaxPayer to be an interface 2 3 Taxpayer [ 4 I/add, abstract methods to this interface 5 6 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions