Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Write a Java class called Employee (Parts of the code is given below), which has two private fields id (int) and salary (int) and

JAVA image text in transcribed
Write a Java class called Employee (Parts of the code is given below), which has two private fields id (int) and salary (int) and three methods raise Salary(double percent), getBonus(double percent) and toString(). Write the necessary constructors and accessor methods and mutator methods, raiseSalary) method takes the percent and increases the salary on that percent. getBonus() method takes a percentas parameter and returns the bonus value as that percent of the salary.toString method should return the id and the salary. For example, if you print out the object with id 123 and width salary of $4000 than it should print Employee 123 has a salary of $4000 public class Employee private int id; public void raiseSalary (double percent) { salary = (int) ((double) salary* (1+percent)); public void getBonus (double percent) [ Write a client program called EmployeeClient that creates a Employee object called El and initialize id and salary at the time of creating the object using the constructor. Call the raise Salary method to enlarge salary by 5% and call the toString method to print the employee id and salary. Then, calculate the bonus for El of 30 of salary and print El bonus using System.out.println(). Create another object called E2 without initializing it and display the id and salary for this object. Then use the accessor/mutator methods to assign id and salary. Print the object E2 using System.out.println()

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

Building The Data Lakehouse

Authors: Bill Inmon ,Mary Levins ,Ranjeet Srivastava

1st Edition

1634629663, 978-1634629669

More Books

Students also viewed these Databases questions

Question

Why does the United States operate under a dual banking system?

Answered: 1 week ago