Write a definition for a structure type for records consisting of a person’s
wage rate, accrued vacation (which is some whole number of days), and
status (which is either hourly or salaried). Represent the status as one of
the two char values 'H' and 'S'. Call the type EmployeeRecord.
C++ PROGRA CODE:
//Header section
#include <iostream>
using namespace std;
// Define the structure type EmployeeRecord
struct EmployeeRecord
{
double wageRate; // Wage rate of the employee
int accruedVacation; // Number of accrued vacation days
char status; // Status of the employee ('H' for hourly, 'S' for salaried)
};
int main()
{
// Create an instance of EmployeeRecord
EmployeeRecord employee1;
// Assign values to the fields of the structure
employee1.wageRate = 15.50;
employee1.accruedVacation = 10;
employee1.status = 'H';
// Print the values of the fields
cout << "Employee Record:" << endl;
cout << "Wage Rate: $" << employee1.wageRate << endl;
cout << "Accrued Vacation: " << employee1.accruedVacation << " days" << endl;
cout << "Status: " << (employee1.status == 'H' ? "Hourly" : "Salaried") << endl;
return 0;
}
// Define the structure type EmployeeRecord
struct EmployeeRecord
{
double wageRate; // Wage rate of the employee
int accruedVacation; // Number of accrued vacation days
char status; // Status of the employee ('H' for hourly, 'S' for salaried)
};
int main() {
// Create an instance of EmployeeRecord
EmployeeRecord employee1;
// Assign values to the fields of the structure
employee1.wageRate = 15.50;
employee1.accruedVacation = 10;
employee1.status = 'H';
// Print the values of the fields
cout << "Employee Record:" << endl;
cout << "Wage Rate: $" << employee1.wageRate << endl;
cout << "Accrued Vacation: " << employee1.accruedVacation << " days" << endl;
cout << "Status: " << (employee1.status == 'H' ? "Hourly" : "Salaried") << endl;
return 0;
}
OUTPUT OF THE PROGRAM CODE:
Employee Record:
Wage Rate: $15.5
Accrued Vacation: 10 days
Status: Hourly