Create a UEmployee class that contains member variables for the university employee name and salary. The UEmployee class should contain member methods for returning the employee name and salary. Create Faculty and Staff classes that inherit the UEmployee class. The Faculty class should include members for storing and returning the department name. The Staff class should include members for storing and returning the job title.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

PLEASE DO IN JAVA (for programs like Eclipse)

Create a UEmployee class that contains member variables for the university employee name and salary.
The UEmployee class should contain member methods for returning the employee name and salary.
Create Faculty and Staff classes that inherit the UEmployee class. The Faculty class should include
members for storing and returning the department name. The Staff class should include members for
storing and returning the job title.

 

I have this code, but it does not work for me 

 


package UEmployee; 
import java.util.*;

class UEmployee
{
//delaration of name and salary
String empName;
double salary;
//constructor of UEmployee
UEmployee(String empName,double salary)
{
this.empName=empName;
this.salary=salary;
}
//function to return the employee name
String getName()
{
return empName;
}

//function to return the salary
double getSalary()
{
return salary;
}
}


class Faculty extends UEmployee
{
String deptName;
//constructor of the Faculty
Faculty(String nm,double sal,String dnm)
{
//passing the name and salary to superclass constructor
super(nm,sal);
deptName=dnm;
}

//function to return department name
String getDeptName()
{
return deptName;
}
}

class Staff extends UEmployee
{
String jobTitle;

//constructor of Staff class
Staff(String nm,double sal,String title)
{
//passing the name and salary to superclass constructor
super(nm,sal);
jobTitle=title;
}

//function to return job title
String getJobTitle()
{
return jobTitle;
}
}


//test or driver class
class Test
{
public static void main(String args[])
{

//accepting the required values from user using Scanner class
String nameF,nameS,dname,title;
double salF,salS;
Scanner sc=new Scanner(System.in);

System.out.print(“\nEnter the faculty name: “);


nameF=sc.nextLine();


System.out.print(“Enter the salary: “);
salF=sc.nextDouble();

System.out.print(“Enter the department name: “);
dname=sc.next();

sc.nextLine();
System.out.print(“\nEnter the staff name: “);
nameS=sc.nextLine();
System.out.print(“Enter the salary: “);
salS=sc.nextDouble();
System.out.print(“Enter the Job title: “);
title=sc.next();


//Instantiation of Faculty class
Faculty fac=new Faculty(nameF,salF,dname);
System.out.println(“\n\nDetails of Faculty:”);
System.out.println(“-———————————“);
//calling all the methods of Faculty
System.out.println(“Name: “+fac.getName());
System.out.println(“Salary: $”+fac.getSalary());
System.out.println(“Departname: “+fac.getDeptName());


//Instantiation of staff class
Staff st=new Staff(nameS, salS,title);
System.out.println(“\n\nDetails of Staff:”);
System.out.println(“-———————————“);
//calling all the methods of Staff
System.out.println(“Name: “+st.getName());
System.out.println(“Salary: $”+st.getSalary());
System.out.println(“Job Title: “+st.getJobTitle());
System.out.println(“\n”);

}
}

Exercise 1
UEmployee, Faculty, Staff
Create a UEmployee class that contains member variables for the university employee name and salary.
The UEmployee class should contain member methods for returning the employee name and salary.
Create Faculty and Staff classes that inherit the UEmployee class. The Faculty class should include
members for storing and returning the department name. The Staff class should include members for
storing and returning the job title.
Transcribed Image Text:Exercise 1 UEmployee, Faculty, Staff Create a UEmployee class that contains member variables for the university employee name and salary. The UEmployee class should contain member methods for returning the employee name and salary. Create Faculty and Staff classes that inherit the UEmployee class. The Faculty class should include members for storing and returning the department name. The Staff class should include members for storing and returning the job title.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
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
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education