Question

Create a date class with attributes of month, day, and year. Create an employee class for...

  1. Create a date class with attributes of month, day, and year.

  2. Create an employee class for storing information related to

    employee information for the CS1C Corporation. This class should contain the employee’s name, employee’s Id, phone number, age, gender, job title, salary, and hire date.

    1. You should write a series of member functions that change the employee’s name, employee’s Id, phone number, age, job title, salary, and hire date.

    2. You should use your date class (composition) when accessing hire date.

    3. You should write a print function that prints all information related to an employee.

    4. You should write a client to test all your member functions. Print the before and after when testing your change functions. You should write at least two different constructors (default and non-default).

  3. Create the following classes:
    1. Programmer class that is derived from the employee class

    with the following private data members i. Department number

    ii. Supervisor’s name
    iii. Percentage of last salary increase

    iv. A C++ identifier (true if the employee knows C++)
    v. A Java identifier (true if the employee knows Java)

    2. Software architect class that is derived from the employee class with the following private data members

    i. Department number ii. Supervisor’s name

iii. Percentage of last salary increase
iv. Years of experience designing software projects

  1. You should write at least two different constructors (default and non-default) for the classes above.

  2. You should write a series of member functions that change the private data members of the derived classes.

  3. You should write a print function that prints all information related to the Programmer class and the Software architect class.

  4. You should write a client to test all your member functions. Print the before and after when testing your change functions.

One should be able to follow your output without looking at your source code.

Data: C1SCEmployees

Name

Employee’s Id

Phone

Age

Gender

Job title

Salary

Hire Date

Jimmy Fallon

12345

949-555-1234

40

M

Comedian

$100,000

8/31/2014

Stephan Colbert

12346

310-555-5555

51

M

Comedian

$70,123

05/08/2015

James Corden

87654

703-703-1234

37

M

Talk Show Host

$900,000

12/25/2014

Katie Couric

77777

203-555-6789

58

F

News reporter

$500,500

03/01/2005

HW03 – Class Constructors, Inheritance & Init [100 pts] Programmers

Name

Employee’s Id

Phone

Age

Gender

Job title

Salary

Hire Date

Sam Software

54321

819-123-4567

21

M

Programmer

$223,000

12/24/2011

Mary Coder

65432

310-555-5555

28

F

Programmer

$770,123

02/08/2010

Name

Department

Supervisor’s Name

Raise %

C++ Knowledge

Java Knowledge

Sam Software

5432122

Joe Boss

4

Yes

No

Mary Coder

6543222

Mary Leader

7

Yes

Yes

Software Architects

Name

Employee’s Id

Phone

Age

Gender

Job title

Salary

Hire Date

Alex Arch

88888

819-123-4444

31

M

Architect

$323,000

12/24/2009

Sally Designer

87878

310-555-8888

38

F

Architect

$870,123

02/08/2003

Name

Department

Supervisor’s Name

Raise %

Years of experience

Alex Arch

5434222

Big Boss

5

4

Sally Designer

6543422

Big Boss

8

I wrote all the code but I'm get errors of redefinition and not sure why,

it's too much to post here trying to get someone to help me with it.

Thank you.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

class Date
{
private int month,day,year;
public Date(int month,int day,int year)
{
this.month = month;
this.day = day;
this.year = year;
}
public String toString()
{
return month+"/"+day+"/"+year;
}
  
}

class Employee
{
private String empName,phone,title;
private int empId ,age;
private Date hireDate;
private char gender;
  
public Employee()
{
empName = "";
phone = "";
title = "";
empId = 0;
age = 0;
  
}
public Employee(String empName,String phone,String title,int empId,int age,Date hireDate,char gender)
{
this.empName = empName;
this.phone = phone;
this.title = title;
this.empId = empId;
this.age = age;
this.hireDate = hireDate;
this.gender = gender;
}
public void setEmpName(String empName)
{
this.empName = empName;
}
public void setEmpId(int empId)
{
this.empId = empId;
}
public void setPhone(String phone)
{
this.phone = phone;
}
public void setTitle(String title)
{
this.title = title;
}
public void setAge(int age)
{
this.age = age;
}
public void setHiredate(Date hireDate)
{
this.hireDate = hireDate;
}
public void setGender(char gender)
{
this.gender = gender;
}
  
  
public void print()
{
System.out.println("Employee Id : "+empId +" Name : "+empName+" Phone : "+phone+" Title : "+title);
System.out.println("Age : "+age +" Hire date : "+hireDate+" Gender : "+gender);
}
}

class Programmer extends Employee
{
private int deptNo;
private String supervisor;
private double raise;
private boolean knowsC;
private boolean knowsJava;
  
public Programmer()
{
deptNo = 0;
supervisor = "";
raise = 0.0;
knowsC = false;
knowsJava = false;
  
  
}
public Programmer(String empName,String phone,String title,int empId,int age,Date hireDate,char gender,int deptNo,String supervisor, double raise, boolean knowsC,boolean knowsJava)
{
super(empName,phone,title,empId,age,hireDate,gender);
this.deptNo = deptNo;
this.supervisor = supervisor;
this.raise = raise;
this.knowsC = knowsC;
this.knowsJava = knowsJava;
  
}
  
public void setDeptNo(int deptNo)
{
this.deptNo = deptNo;
  
}
public void setSupervisor(String supervisor)
{
this.supervisor = supervisor;
}
public void setRaise(double raise)
{
this.raise = raise;
}
public void setKnowsJava(boolean knowsJava)
{
this.knowsJava = knowsJava;
}
public void setKnowsC(boolean knowsC)
{
this.knowsC = knowsC;
}
public void print()
{
super.print();
System.out.println(" Department Number: "+deptNo+" Supervisor : "+supervisor+" salary raise percent : "+raise);
System.out.println(" knows java : "+knowsJava+" knows c++ : "+knowsC);
}
  
}

class SoftwareArchitect extends Employee
{

private int deptNo;
private String supervisor;
private double raise;
private int experience;
  
public SoftwareArchitect()
{
deptNo = 0;
supervisor = "";
raise = 0.0;
experience = 0;
  
}
public SoftwareArchitect(String empName,String phone,String title,int empId,int age,Date hireDate,char gender,int deptNo,String supervisor,double raise, int experience)
{
super(empName,phone,title,empId,age,hireDate,gender);
this.deptNo = deptNo;
this.supervisor = supervisor;
this.raise = raise;
this.experience = experience;
}
public void print()
{
super.print();
System.out.println(" Department Number: "+deptNo+" Supervisor : "+supervisor+" salary raise percent : "+raise);
System.out.println(" experience : " +experience);
}
  
}

class TestEmployee
{
   public static void main (String[] args)
   {
       Employee emp = new Employee("Jimmy fallon","949-555-1234","Comedian",12345,40,new Date(8,31,2014),'M');
       emp.print();

       Programmer p = new Programmer("Sam Software","819-123-4567","Programmer",54321,21,new Date(12,24,2011),'M',5434212,"Joe Boss",4,true,false);
       p.print();
  
       SoftwareArchitect sa = new SoftwareArchitect("Alex Arch","819-123-4444","Architect",88888,31,new Date(12,24,2009),'M',5434222,"Big Boss",5,4);
       sa.print();
   }
}

Output:

Employee Id : 12345 Name : Jimmy fallon Phone : 949-555-1234 Title : Comedian
Age : 40 Hire date : 8/31/2014 Gender : M


Employee Id : 54321 Name : Sam Software Phone : 819-123-4567 Title : Programmer
Age : 21 Hire date : 12/24/2011 Gender : M
Department Number: 5434212 Supervisor : Joe Boss salary raise percent : 4.0
knows java : false knows c++ : true


Employee Id : 88888 Name : Alex Arch Phone : 819-123-4444 Title : Architect
Age : 31 Hire date : 12/24/2009 Gender : M
Department Number: 5434222 Supervisor : Big Boss salary raise percent : 5.0
experience : 4

Do ask if any doubt. Please upvote.

Add a comment
Know the answer?
Add Answer to:
Create a date class with attributes of month, day, and year. Create an employee class for...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Design and write a class named Employee that inherits the Person class from the previous exercise...

    Design and write a class named Employee that inherits the Person class from the previous exercise and holds the following additional data: ID number, department and job title. Once you have completed the Employee class, write a Python program that creates three Employee objects to hold the following data: Name ID Number Department Job Title Phone Susan Meyers 47899 Accounting Vice President 212-555-1212 Mark Jones 39119 IT Programmer 212-555-2468 Joy Rogers 81774 Operations Engineer 212-555-9753 The Python program should store...

  • Using C++, Write a class named Employee that has the following member variables: name. A string...

    Using C++, Write a class named Employee that has the following member variables: name. A string that holds the employee's name. idNumber. An int variable that holds the employee's ID number. department. A string that holds the name of the department where the employee works. position. A string that holds the employee's job title. The class should have the following constructors: A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee's name,...

  • c++ only Design a class representing an Employee. The employee would have at least these private...

    c++ only Design a class representing an Employee. The employee would have at least these private fields (Variables): name: string (char array) ID: string (char array) salary: float Type: string (char array) All the variables except for the salary should have their respective setters and getters, and the class should have two constructors, one is the default constructor and the other constructor initializes the name,ID and type of employee with valid user input. The class should have the following additional...

  • Define a class named Employee . Derive this class from the class Person. An employee record...

    Define a class named Employee . Derive this class from the class Person. An employee record inherits an employee's name from the class Person. In addition, an employee record contains an annual salary (represented by a single value of type double), a hire date that gives the year hired (as a single value of type int), an identification number of type int, and a department of type String. Give your class a reasonable complement of constructors, accessors, mutators, an equals...

  • Create a c++ code and answer number 1 Homework Ch. 13 - Employee Class 30 points...

    Create a c++ code and answer number 1 Homework Ch. 13 - Employee Class 30 points Design a class named Employee that has the following attributes: * Name ID Number- (Employee's] Identification Number " Department-the name of the department where the employee works " Position-the employee's job title The class should have the following constructors: A constructor that accepts values for all the member data as arguments A constructor that accepts the following values as arguments and assigns them to...

  • Create a Java application, that support the following: Create an Employee class, which holds following information:...

    Create a Java application, that support the following: Create an Employee class, which holds following information: Employee First Name Employee Last Name Employee Phone Number Employee Address Employee id Employee Title Employee salary Create an application that uses the Employee class Constructors –Getters and setters A minimum of 3 constructors including default constructor equals() method Helper methods toString() method Create an array of 5 Employee objects Use a Scanner to read in 5 employee information Change 2 employees information (3-items...

  • Part (A) Note: This class must be created in a separate cpp file Create a class...

    Part (A) Note: This class must be created in a separate cpp file Create a class Employee with the following attributes and operations: Attributes (Data members): i. An array to store the employee name. The length of this array is 256 bytes. ii. An array to store the company name. The length of this array is 256 bytes. iii. An array to store the department name. The length of this array is 256 bytes. iv. An unsigned integer to store...

  • Create a C# Console program. Add a class named Employee that has the following public fields:...

    Create a C# Console program. Add a class named Employee that has the following public fields: • Name. The name field references a String object that holds the employee’s name. • IDNumber. The IDNumber is an int that holds the employee’s ID number. • Department. The department field is a String that holds the name of the department where the employee works. • Position. The position field is a String that holds the employee’s job title. Once you have written...

  • Write a C++ program Write a class named Employee that has the following member variables: name...

    Write a C++ program Write a class named Employee that has the following member variables: name A string that holds the employee name idNumber An int to hold employee id number department A string to hold the name of the department position A string to hold the job position The class will have three constructors: 1. A constructor that accepts all the internal data such as: Employee susan("Susan Meyers", 47899, "Accounting", "Vice President"); 2. A constructor that accepts some of...

  • It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming...

    It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming Challenge 2 Employee Class.pdf Program Template: // Chapter 13, Programming Challenge 2: Employee Class #include <iostream> #include <string> using namespace std; // Employee Class Declaration class Employee { private: string name; // Employee's name int idNumber; // ID number string department; // Department name string position; // Employee's position public: // TODO: Constructors // TODO: Accessors // TODO: Mutators }; // Constructor #1 Employee::Employee(string...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT