Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Employee and Salary Class - java programming fundamentals II I wrote this code myself based off the prompt my professor provided in the first image,

Employee and Salary Class - java programming fundamentals II

image text in transcribed

image text in transcribed

image text in transcribed

I wrote this code myself based off the prompt my professor provided in the first image, yet I struggle to understand the direction. Based off previous assignments, and this chapter, he wants me utilize inheritance, arrays, objects and constructors. However, this is an online course so I am struggling a lot with the technicalities of things.

Your help is much appreciated.

Employee and Salary Class Define a class Employee with data members as int employee_id - To store employee ID. String employee_name - To store the name of the employee. Define class Salary which inherits Employee class and has the following characteristics Data members String designation - To store employee designation. double monthly_salary - To store salary of the employee. Methods constructor Salary(int employee_id, String employee_name, String designation, double monthly_salary) - Invokes a superclass constructor and initialize data members. void display() - To display details of employees whose earning is more than 20,000. Details of an employee should be separated by spaces. Input 123 John engineer 40000 124 Emma Testing 33000 125 White Trainee Engineer 20000 where, First line represents the number of employees whose details are provided. Second line represents employee ID. Third line represents employee name. Fourth line represents designation of the employee. Fifth line represents employee salary per month. The remaining lines represent the details of the remaining employees in the same format as given above. Output 123 John engineer 40000.0 124 Emma Testing 33000.0 The output displayed details of employees who earn more than 20,000 + Test Case(s) 1- import java.util.*; 3. class Employee { 4 public int employee_id; 5 public String employee_name; 6 } 7 class Salary extends Employee{ public String designation; public double monthly salary; 10 int count = 0; Employee[] employeeArray = new Employee [20]; 11. 13. 14 16 public Salary(int employee_id, String employee_name, String designation, double monthly salary) { [/initialize data members this.employee_id = employee_id; this.employee_name = employee_name; this.designation = designation; this monthly salary = monthly salary, 18 20 21. 23 public void display() { if(monthly_salary > 20000.0){ System.out.print(employee_id); System.out.print(employee_name); System.out.print(designation); System.out.print(monthly_salary); } 27 28 } 29 public class Solution { 30 public static void main(String[] args) { //Write your code here Scanner input = new Scanner(System.in); int employee_id = input.nextInt(); String employee_name; String designation; double monthly salary; Salary mySalary = new Salary(employee_id, employee_name, designation, monthly salary); mySalary.display(); 41 }

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

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

3540416641, 978-3540416647

More Books

Students also viewed these Databases questions