(Employee Class) Create a class called Employee that includes three instance variables—a first name (type String), a last name (type String) and a monthly salary (double). Provide a constructor that initializes the three instance variables. Provide a set and a get method for each instance variable. If the monthly salary is not positive, do not set its value. Write a test app named EmployeeTest that demonstrates class Employee’s capabilities. Create two Employee objects and display each object’s yearly salary. Then give each Employee a 10% raise and display each Employee’s yearly salary again.
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Additional Engineering Textbook Solutions
Programming in C
Starting Out with Python (4th Edition)
Problem Solving with C++ (9th Edition)
Starting Out with C++: Early Objects (9th Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
- Please fill in the blanks for the following statements: The class function with no return type that is used to initialize data members is called the __________________________.arrow_forwardHow we can access protected data members of a class without the use of public or private functions? Explain with codearrow_forwardPrompt We have learned how to use accessor and mutator methods to access private class member data. It is possible to instead make the class members public, which would allow other programs to directly retrieve and modify the class member data without needing to write the accessor and mutator methods. This is usually considered bad practice. Why do you think that is? What do you think the benefits are to writing accessor and mutator methods instead of just leaving the variables public? Below is the definition for a class called Counter. Define a new method for this class called "findDifference". This method should take another Counter object as an argument and return the difference in the counts between the counter being called and the one passed as an argument. The difference should be given as an absolute value (not returned as a negative). See below the class definition for examples of this method being used. public class Counter {private int count;public Counter() {count =…arrow_forward
- 8. What is the difference between equals() and method and == operator?.arrow_forwardState whether it is true or false. If false, explain why? " Referring to a derived-class object with a base-class handle is dangerous. "arrow_forwardImplement the following class and write a driver classarrow_forward
- C++ please, Specify, design, and implement a class that can be used in a program that simulates a combination lock. The lock has a circular knob, with the numbers 0 through 39 marked on the edge, and it has a three-number combination, which we'll call x, y, z. To open the lock, you must turn the knob clockwise at least one entire revolution, stopping with x at the top; then turn the knob counter-clockwise; stopping the second time that y appears at the top; finally turn the knob clockwise again, stopping the next time the z appears at the top. At this point the lock will be open. Your lock class should have a constructor that initializes the three-number combination (use 0,0,0 for default arguments). Also provide member functions: a. To alter the lock's combination b.To turn the knob in a given direction until a specified number appears on top c. To close the lock d. To attempt to open the lock e. To inquire the status of the lock (open or shut) f. To tell you what number is currently…arrow_forwardAll needed parameters must be passed in during method call.arrow_forwardWhen a void method is executing, what happens when the end of the method is reached?arrow_forward
- 2. Import Classa) Implement a class Rectangle with two attributes, width and height. b) Implement an init method with an optional parameter type. Set the default value of the attributes of width and height to 1.c) Implement a display method to print the values of width and height.d) Implement a setWidth method to assign width to the instance variable.e) Implement a setHeight method to assign height to the instance variable.f) Implement a getWidth method to return the value of the instance variable width.g) Implement a getHeight method to return the value of the instance variable height.h) Implement an area method to return the value of area of a rectangle.i) Save Rectangle class as rectangle.py.j) Import Rectangle class from rectangle.py.k) Employs the Rectangle class methods above to set and get various measurements of a rectangle. 1) Instantiate two objects of type rectangle, one with arguments one without. r1 = Rectangle(4, 5)r2 = Rectangle() 2) Call display() to print width and…arrow_forward8- Create an instance of the following class and call its methods class Exam( int grade; public: void seta(int b) (gtade=b;) int petal) (return grade:) i;arrow_forwardc. Oforiwaa a student of the java class also produced the code below in a class discussion. Salamatu, again said that Oforiwaa’s code was incomplete and was seconded by Joshua another student of the class.Correct the code without changing the access type of the variables salary, name and pension. Using the object variable shito, initialize the variables salary, name and pension to 2000, Joshua Adamson and 120 respectively. Insert a code to display salary, name and pension. package wednesdayClass;class Wuntumi{private double salary;private String name;private float pension;}public class Sowh3 extends Wuntumi {public static void main(String footbal[]) {Wuntumi sobolo = new Wuntumi();}}d. Explain why the code was incorrect.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education