subject

Computer Programming 1 Homework 2
Write a Java program that stores information about a company. You should define two classes: Employee which represents the employees in the company, and Department which represents the departments the employees are in.
Class definition
The classes should have the following fields:
▪ Department
• String name
▪ Employee
• String firstName
• String lastName
• double salary
• Department department
Notes:
1. All fields should be private.
2. You should define a constructor that takes as parameters all fields in each class.
3. You should define a getter and a setter for all fields in each class.
4. The field salary on class Employee should never be a negative number.
5. You should define a method getFullName on class Employee that returns the employees full name as a String.
Main Program
after you have defined the classes, In the main method define two objects of type Department as follows:
#
name
1
Sales
2
Accounting
Then define an array of type Employee and fill it with the following Employee objects:
#
firstName
lastName
salary
department
1
John
White
1000
Department object 1 (Sales)
2
David
Ford
1500
Department object 1 (Sales)
3
Sophie
Beech
1200
Department object 1 (Sales)
4
Mary
Howe
1300
Department object 2 (Accounting)
5
Susan
Brand
1400
Department object 2 (Accounting)
the program should show the user the following menu and wait for input from the user:
1. Show all employees
2. Show employees for department
3. Show employee with max salary
Option 1: shows the employee’s full name, salary and department name for all employees
Option 2: asks the user for a department name then shows the employee’s full name, salary and department name for that department.
Option 3: shows the full name, salary and department name for the employee with the maximum salary in the company


Computer Programming 1

Homework 2
Write a Java program that stores information about a company. Y

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 01:50
A.) generate scaffolding to create database for your application. develop all the entities identified in assignment #2. add any additional that may be identified later. b.) add data validation rules to the models that are appropriate for your application and data. c.) create links for each scaffold in the header section. part 2: application updates [30 points] a.) add two additional views to the "home" controller you created in assignment #1. b.) the two views should be named as “privacy" and "". c.) link the two newly created views in the footer section. hint: you would need to modify the “home" controller definition and create “privacy.html.erb" and “.html.erb" files in appropriate locations.
Answers: 3
question
Computers and Technology, 22.06.2019 19:20
1)consider the following code snippet: #ifndef book_h#define book_hconst double max_cost = 1000.0; class book{public: book(); book(double new_cost); void set_cost(double new_cost); double get_cost() const; private: double cost; }; double calculate_terms(book bk); #endifwhich of the following is correct? a)the header file is correct as given.b)the definition of max_cost should be removed since header files should not contain constants.c)the definition of book should be removed since header files should not contain class definitions.d)the body of the calculate_terms function should be added to the header file.
Answers: 1
question
Computers and Technology, 22.06.2019 19:30
When creating a presentation in libre office impress, where does the editing of slides take place? a. the slides panel b. the center panel c. the tasks panel, under the masters pages tab d. the tasks panel, under the layouts tab
Answers: 3
question
Computers and Technology, 24.06.2019 03:00
With editing, word automatically displays a paste options button near the pasted or moved text. a. cut-and-paste b. drag-and-drop c. inline d. copy-and-carry
Answers: 1
You know the right answer?
Computer Programming 1 Homework 2
Write a Java program that stores information about a compa...
Questions
question
Mathematics, 30.09.2019 18:10
question
Mathematics, 30.09.2019 18:20
Questions on the website: 13722361