Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Write a java
- The classes Name and Date are separate classes used as properties in the Employee class.
- Class Employee is the superclass of the classes SalariedEmployee and HourlyEmployee. The superclass has the attributes name and data of hire and methods to set and get these attributes. It also has 2 abstract methods equals() which check if the objects are same and toString() which convert the properties to a printable string. Also the method read() which used as an input method.
- The SalariedEmployee subclass has in addition to the attributes of the super-class the attribute annualSalary and set and get methods for it. This class also defines the read() method and grossPay() which in this case returns the salary of the employee.
- The HourlyEmployee subclass has in addition to the attributes of the super-class, the hoursWorked and hourlyRate attributes. It provides ‘get’ and ‘set’ methods for these attributes. Also it provides the methods equals() and toString(). Finally, it provides an implementation of the method grossPay(), which returns the product of the hourly rate with the hours worked for each employee.
After creating this class hierarchy create a Main class with a main function. This function will have an array of type Employee and size 2. Place in the position 0 of this array a SalariedEmployee object and in the position 1 an HourlyEmployee object. Then set some appropriate values for the two objects. Finally create a loop that calls the grossPay() method on both objects of the array and display the returned value.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Java program: The class diagram with four classes Mammal, Human, Student and Doctor is given. The Mammal class is given as well. Write down the remaining classes as described in the class diagram. The fields and methods for each class is given in the attachment. //in Mammel.java Public interface Mammal{ public double hairColor(): } 1. Class Human: Fields: age(int), weight(double), height(double) Methods: getAge, getWeight, getHeight 2. Class Student: Fields: major (String), gpa (double), creditHours (int) methods: getMajor: returns major, getGpa: returns gpa, getYear: returns freshman, sophmore, junior, senior as determined by earned credit hours Freshman : less than 32 credit hours sophmore: at least 32 but less than 64 credit hours junior: at least 64 credit hours but less than 96 credit hours senior: at least 96 credit hours 3.Class Doctor: Fields: years(int), Speciality (String) methods: getYears: returns years, getSpeciality: returns speciality, getSalary: calculates…arrow_forwardwrite the code in java for this problemarrow_forwardClass A is the parent class, while classes B and C are the subclasses of A. Both B and C contain several features and techniques that are equivalent to one another; nevertheless, the implementations of some of their methods are quite different between the two. Explain what kind of class A will be using logic; is it going to be a concrete class, an abstract class, or an interface?arrow_forward
- Answer with True or False for the following. Explain your answers.-It is legal to write a method in a class which overloads another method declared in the same.-It is legal to write a method in a superclass which overrides a method declared in a sub-class.arrow_forwardIn order to qualify as a subclass of an abstract class, a class must offer concrete implementations for all of the abstract methods defined in the abstract parent class. Exactly how do you feel about this?arrow_forwardWrite a Java program A2p1.java with a public class A2p1 and no named packages to read from stdin information for several singers and dancers. You should design a superclass Person with appropriate constructor(s) to initialize member variables such as name (of type String), sex (of type String) and age (of type int). You should design two additional subclasses Singer and Dancer of the Person class with appropriate constructor(s) to initialize additional member variables such as favorite (of type String). You can add the toString method to these three classes to provide a suitable string representation for objects of these classes. Put all four classes in the same file. A sample run can look like the following (you can also try running it with standard input redirection): [~/temp] $ java A2p1 [kwang@computer] How many persons do you want to input? 3 Enter information for person 1: Name: Tom Sex ('F' or 'M') : M Age: 18 Singer or Dancer ('S' or 'D'): S Favorite song: songl Enter…arrow_forward
- Write the definition of classes and interfaces in the given diagram using following details: a) Interface shape has a method draw(). b) Override the method draw() in all subclasses. c) Define a non-abstract method fillColor() in Circle class. (I want the complete solution using the codes in bluej program also diagram) bluej java coodarrow_forwardState a circumstance in which you would prefer an interface over an abstract class. Also, State a circumstance in which you would prefer an abstract class over an interface.arrow_forwardWrite a program in Java to perform the followings, (i) Design one parent and two child classes. Names of parent and child classes along with the names of their variables and methods should be taken from real-life by yourself. Parent class should have at least two variables, one parameterized constructor and one method to perform any meaningful operation/calculation with the variables. Child classes should have at least one additional variable declared within (ii) (iii) them and one parameterized constructor, and a toString method. (iv) Design another class and a main method inside it. Declare at least one object of each of the two child classes using parameterized constructor. Call the method of the parent class with these objects to perform the particular operation/calculation on these objects and show the result. Display values of all the variables of these objects using toString. Write the Java program using Eclipse IDE, copy and paste the code along with the output in a word file.…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education