Computers and Technology
Computers and Technology, 08.05.2021 16:40, kiki8734

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

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 01:30, yudayang2012pa9u8p
Consider the following statements: #include #include class temporary { private: string description; double first; double second; public: temporary(string = "", double = 0.0, double = 0.0); void set(string, double, double); double manipulate(); void get(string& , double& , double& ); void setdescription(string); void setfirst(double); void setsecond(double); }; write the definition of the member function set() so that the instance variables are set according to the parameters. write the definition of the constructor so that it initializes the instance variables using the function set() write the definition of the member function manipulate() that returns a decimal number (double) as follows: if the value of description is "rectangle", it returns first * second if the value of description is "circle" it returns the area of a circle with radius first if the value of description is "cylinder" it returns the volume of a cylinder with radius first and height second. hint: the volume of a cylinder is simply the area of the circle at the base times the height. if the value of description is "sphere" it returns the volume of the sphere with radius first. otherwise it returns -1.0;
Answers: 1
image
Computers and Technology, 22.06.2019 10:30, icantspeakengles
Aconstruction company is creating a powerpoint presentation describing how they calculate costs during each construction step. they plan to email this presentation to clients. the individual clients will be watching the presentation slide show on their own personal computers. what is the most important formatting step the company should take to make the text readable and pleasing to the eye?
Answers: 2
image
Computers and Technology, 23.06.2019 02:30, chaaaa
People with high self-esteem: accept their strengths and weaknesses. believe that failed experiences are failures of their whole self. feel good about who they are only when they reach total success. need positive external experiences to counteract negative feelings that constantly plague them.
Answers: 1
image
Computers and Technology, 23.06.2019 07:10, anika420
If you want to import a picture into a dtp application, what must you do first? draw an image frame. import text. open the folder containing the file. select get image… from the windows menu.
Answers: 2
Do you know the correct answer?
Computer Programming 1 Homework 2
Write a Java program that stores information about a compa...

Questions in other subjects: