plz help me to give solution for this program

C++ using Classes

Page 1 of 1

3 Replies - 775 Views - Last Post: 12 April 2009 - 05:36 AM Rate Topic: -----

#1 dinesh411  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 11-April 09

plz help me to give solution for this program

Post icon  Posted 11 April 2009 - 07:28 PM

Part 1: Employee database
Aim
As a co-op student you are working for a company. The manager has approached you to help input
employee’s information into the database in a proper way. The information includes staff ID
number, the types of the jobs (part-time or full-time), staff’s birthday and hire date.
The aim of this assignment is to define and test two classes named Employee and Date that save
and validate employee’s information.
The Date class
The Date class will accept and validate the date. If it’s valid, print the date in a proper way. If not,
send the error messages.
The class has the following private data members:
. an int named day that stores the day. It chooses between 1 and 31 based on month.
. an int named month that stores the month. It chooses between 1 and 12.
. an int named year that stores the year.
The class has the following public member functions:
. a constructor that accepts the day, month and year of the date as arguments. Check month.
If it’s invalid, set it to 1. Call function checkDay() to check day. If no value are specified
when the object is declared, the default values are assigned to 1, 1 and 1900, respectively.
. an int checkDay() function that tests proper day for month and year. If the date is invalid, send
error messages and assign day to 1. For example, there are 31 days in January but 30 days in
April. 29 days exist in the February of Year 2000, but only 28 days exist in the February of
Year 2009. Why? As we know, leap year! You can use following formula to check leap year:
if (year % 400 ==0) || (year % 4 == 0 && year % 100 != 0) that year is a leap year.
. a print() function that prints the date in mm/dd/yyyy format.
All functions containing more than one statement should be defined outside the class definition.
The header file for the Date class should be called Date.h and implementation file, Date.cpp.
The Employee class
The Employee class will hold the information of the staff.
The class has four private data members:
. a double staffID stores the ID number of the employee.
 a char type stores the type of job, and P represents part-time and F represents full-time.
. a const Date birthDate stores the birthday of the employee.
. a const Date hireDate stores the hire date of the employee.
The class has following public member functions:
. a constructor that sets staffID and type, and calls Date class to set the birthDate and
hireDate as well.
. a print() function prints the staff ID number and the type of job.
All functions containing more than one statement should be defined outside the class definition.
The header file for the Employee class should be called Employee.h and implementation file,
Employee.cpp.
Testing
Test your Date and Employee classes with the driver program. Note that the supplied driver program
may not test all of the member functions you have built. You should, however, ensure that the functions
not tested by this driver program are correctly programmed. Your classes will be tested with the
supplied driver program.

Part 2: Complex Class
In this part, you are required to design a Complex class. A number of the form a + ib, where i2 = -1, and
a and b are real numbers, is called a complex number. We call a the real part and b the imaginary part of
a + ib. Complex numbers can also be represented as ordered pairs (a, B). The addition and
multiplication of complex numbers is defined by the following rules:
(a, B) + (c, d) = ((a + c), (b + d)) and (a, B) * (c, d) = ((ac – bd), (ad + bc)).
The class has the following private data members:
. a double named realPart that stores the real part of the complex.
. a double named imaginaryPart that stores the imaginary part of the complex.
The class has the following public member functions:
. a constructor that accepts the real and imaginary parts of the complex as arguments. If no value is
specified when the object is declared, the default values are assigned to 0.
. an overloaded operator+() function that overloads the standard + math operator.
. an overloaded operator*() function that overloads the standard * math operator.
And, the friend functions of the class:
. an overloaded operator<<() function that displays the complex of the form (a, B).
. an overloaded operator>>() function that reads a complex from the keyboard.
The header file for the Complex class should be called Complex.h and the implementation file,
Complex.cpp
Testing
Test your Complex class with the driver program to ensure that the functions are correctly programmed.

Is This A Good Question/Topic? 0
  • +

Replies To: plz help me to give solution for this program

#2 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5313
  • View blog
  • Posts: 27,216
  • Joined: 10-May 07

Re: plz help me to give solution for this program

Posted 11 April 2009 - 07:31 PM

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.
Was This Post Helpful? 0
  • +
  • -

#3 chris772  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 190
  • Joined: 13-March 09

Re: plz help me to give solution for this program

Posted 11 April 2009 - 09:33 PM

If you actually want help, you need to actually do something other than say you need someone to do this for you. In the background of the posting box it says "We Will Not Do Your Homework! You Must Show Us Your Code."
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,516
  • Joined: 23-August 08

Re: plz help me to give solution for this program

Posted 12 April 2009 - 05:36 AM

To Homework
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1