Question

Create a structure called employee that contains two members: an employee number (type int) and the...

Create a structure called employee that contains two members: an employee number (type int) and the employee’s compensation (in dollars; type float). Ask the user to fill in this data for three employees, store it in three variables of type struct employee, and then display the information for each employee.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>

using namespace std;

struct employee {
    int number;
    float compensation;
};

int main() {
    employee e1, e2, e3;
    cout << "Enter employee number of first employee: ";
    cin >> e1.number;
    cout << "Enter compensation of first employee: ";
    cin >> e1.compensation;
    cout << "Enter employee number of second employee: ";
    cin >> e2.number;
    cout << "Enter compensation of second employee: ";
    cin >> e2.compensation;
    cout << "Enter employee number of third employee: ";
    cin >> e3.number;
    cout << "Enter compensation of third employee: ";
    cin >> e3.compensation;
    
    cout << "Employee 1:" << endl;
    cout << "Employee number: " << e1.number << endl;
    cout << "Compensation: " << e1.compensation << endl << endl;
    cout << "Employee 2:" << endl;
    cout << "Employee n33umber: " << e2.number << endl;
    cout << "Compensation: " << e2.compensation << endl << endl;
    cout << "Employee 3:" << endl;
    cout << "Employee number: " << e3.number << endl;
    cout << "Compensation: " << e3.compensation << endl << endl;
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
Create a structure called employee that contains two members: an employee number (type int) and the...
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
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