-4

Create a c++ program which accepts an employee’s full name, hours worked, and pay grade, and displays the employee’s name, and salary. The following data should be stored in parallel arrays.

#include <iostream>

using namespace std;

int main(void)

{
    string firstnamearr[10] = {" "," "," "," "," "," "," "," "," "," "};
    string lastnamearr[10] = {" "," "," "," "," "," "," "," "," "," "};
    int paygrade[10] = {};
    int hoursworked[10] = {};
    int salary[10] = {};

    cout << "\n The Names,Paygrade,Hoursworked and Salary of employees:";
    cout << "\n -------------------------------------------------------";
    cout << "\n firstname\tlastname\tpaygrade\thoursworked\tsalary";
    cout << "\n ----------------------------------------------------------";

    for(int i = 0; i < 10; i++)
    {
        cout << "\n  " << firstnamearr[i] <<"\t\t" << lastnamearr[i] << "\t\t" << paygrade[i]
             << "\t\t" << hoursworked[i] << "\t\t" << salary[i];
    }
    cout << "\n --------------------------------------------------"<< endl;
    return 0;
}
RedLens834
  • 231
  • 3
  • 18

2 Answers2

1

You should take a look at std::cin.

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
MrPromethee
  • 721
  • 9
  • 18
0

First of all you dont have to fill the arrays just use:

string firstNameArr[10] = {};

etc.

Then just use:

cin >> firstNameArr[0];

etc.

But I would recommend a std::vector as @tobi303 already said its just an Array with dynamic size!

WasteD
  • 758
  • 4
  • 24