Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m having issues getting this started... This is the second time I\'ve posted

ID: 3620705 • Letter: I

Question

I'm having issues getting this started... This is the second time I've posted this question due to the last one not being quite what i was looking for and difficult to follow. 1) Ignore the date class stuff
2) Please give a complete solution (Minus the date class) so I can better understand this... 3) Please do not use cin, instead manually set the values in main.. It makes the examples more simplistic and easier to follow.
Write a console program that implements these classes. In main, write a I'm having issues getting this started... This is the second time I've posted this question due to the last one not being quite what i was looking for and difficult to follow. 1) Ignore the date class stuff
2) Please give a complete solution (Minus the date class) so I can better understand this... 3) Please do not use cin, instead manually set the values in main.. It makes the examples more simplistic and easier to follow.

Explanation / Answer

Dear User, #include<iostream>
using namespace std;
// Member function definitions for Date class.
class Date
{
public:
Date() {      } // default constructor
void setDate();
void print() const; // print date in month/day/year format
private:
int month; // 1-12
int day; // 1-31 based on month
int year; // any year
// utility function to test proper day for month and year
int checkDay( int ) const;
};
void Date:: setDate()
{
int mn,dy,yr;
cout<<"Enter day:";
cin>>dy;
cout<<"Enter month:";
cin>>mn;
cout<<"Enter year";
cin>>yr;
if ( mn > 0 && mn <= 12 ) // validate the month
month = mn;
else {
month = 1;
cout << "Month " << mn << " invalid. Set to month 1. ";
}
year = yr >= 1900 && yr <= 2100 ? yr : 1990;
day = checkDay( dy ); // validate the day
}

// Utility function to confirm proper day value
// based on month and year.
int Date::checkDay( int testDay ) const
{
int daysPerMonth[ 13 ] = { 0, 31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31 };
if ( testDay > 0 && testDay <= daysPerMonth[ month ] )
return testDay;
if ( month == 2 && // February: Check for possible leap year
testDay == 29 &&
( year % 400 == 0 || (year % 4 == 0 && year % 100 != 0 ) ) )
return testDay;
cout << "Day " << testDay << " invalid. Set to day 1. ";

return 1; // leave object in consistent state if bad value
}

// Print Date object in form month/day/year
void Date::print() const
{ cout << month << '/' << day << '/' << year; }
class Employee
{
private:
int ID;
public:
char name[80];
char address[80];
char phone[80];
Date birthDate;
Date hireDate;
Employee(int id);
int GetID();
virtual double getMonthsPay() = 0;
};
Employee::Employee(int id)
{
ID=id;
cout<<"Enter name:";
cin>>name;
fflush(stdin);
cout<<"Enter Address:";
cin>>address;
cout<<"Enter phone no:";
cin>>phone;
birthDate.setDate();
hireDate.setDate();
}
int Employee::GetID()
{
return ID;
}

class SalariedEmployee : public Employee
{
public:
double salary;
double getMonthsPay();
SalariedEmployee(int id);
};
SalariedEmployee::SalariedEmployee(int id):Employee(id)
{
if(id!=0){
cout<<"Enter salary:";
cin>>salary;}
}
double SalariedEmployee::getMonthsPay()
{
return salary;
}
class HourlyEmployee : public Employee
{
public:
double hours;
double hourlyRate;
double getMonthsPay();
HourlyEmployee(int id);
};
HourlyEmployee::HourlyEmployee(int id):Employee(id)
{
cout<<"Enter number of hours:";
cin>>hours;
cout<<"Enter number hourly rate:";
cin>>hourlyRate;
}
double HourlyEmployee::getMonthsPay()
{
return hours*hourlyRate;
}

/* All outsourced employees have an ID code of zero
and are paid a flat salary rate of $20/month. */
class OutsourcedEmployee : public SalariedEmployee
{
public:
double getMonthsPay();
OutsourcedEmployee();
};
OutsourcedEmployee::OutsourcedEmployee():SalariedEmployee(0)
{}
double OutsourcedEmployee::getMonthsPay()
{
return 20;
}

void main()
{
//Hourly Employee class
cout<<"Hourly Employee class:"; //creating object HourlyEmployee emp1(23);
//outputting employee datails
cout<<"ID:"< cout<<"Name:"< cout<<"Address:"< cout<<"Phone:"< cout<<"HireDate:";
emp1.hireDate.print();
cout<<"PAY:"; //Saleried employee class
cout<<"Saleried employee clas"< //crating object
SalariedEmployee emp2(143);
cout<<"ID:"< cout<<"Name:"< cout<<"Address:"< cout<<"Phone:"< cout<<"HireDate:";
emp1.hireDate.print();
cout<<"PAY:"; //Outsourced Employee class
OutsourcedEmployee emp3;
cout<<"ID:"< cout<<"Name:"< cout<<"Address:"< cout<<"Phone:"< cout<<"HireDate:";
emp3.hireDate.print();
cout<<"PAY:"; //pause system for a while
system("pause");

}//end main

I hope this will helps to you
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote