As you see in pp. 638-640, structures are useful to store related data together that defined with different types. Here you are asked to modify the Payroll program that we have been working on previous labs. You are asked to write a program using structures and pointers as shown in the following, and store the in an output file. You may see "Appending a Node to the List" in pp. 1126-1128, and pp. 530-536. #include using namespace std; struct Employee_t { string Fname, Lname; int NofHours; float HourlyRate; char Major (Computer, Security); float Amount; Employee *next }; Employee *head; void print-record (struct *); //use setw() to align fields properly; Last Name ESU CPSC Your Name First Name Komp Scien Add 7 more of your own here... Create a file, Employee.txt. int main() { } # of Hours 30 40 40 for (int count=0; count < NumOfEmp; count++) {. print each line on your screen; //Allocate a new node and store. infile >> newNode->fname; infile >> newNode->NofHours; newNode-> = nullptr; print-record(newNode); *** Hourly Rate 40 30 35 return 0; Amount Comp Sci 2200 Y 2200 Y 3400 Y Comp Sec N N Y

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 18SA
icon
Related questions
Question
the program below is the program that is being referred to in the image,
 
 
using namespace std;
struct varis
{
    string lastName, firstName;
    int hours, rate;
    double pay;
    int major_type[2];
};
void print_Title();
string readName();
int readHours();
int readPayRate();
int readMajor();
double computeAmount(int myMajor, double myPay);
void printRecord(varis info[], int size);

 

int main()
{
    print_Title();
    int size = 10;
    int x = 0;
    varis info[size];

 

    do
    {
        cout << "\nEnter first name, last name, numbers of hours worked, and hourly pay\n";
        info[x].firstName = readName();
        info[x].lastName = readName();
        info[x].hours = readHours();
        info[x].rate = readPayRate();
        info[x].pay = info[x].hours * info[x].rate;
        cout << "Type 1 if you are a Computer Science major or a 0 if you are not: ";
        info[x].major_type[0] = readMajor();
        cout << "Type 1 if you are a Cyber Security major or a 0 if you are not: ";
        info[x].major_type[1] = readMajor();
        info[x].pay = computeAmount(info[x].major_type[0], info[x].pay);
        info[x].pay = computeAmount(info[x].major_type[1], info[x].pay);
        ++x;
    } while (x < size);

 

    cout << endl;
    cout << left << setw(15) << "Last Name" << setw(15) << "First Name" << setw(15) << "# of Hours" << setw(15) << "Hourly Rate"
         << setw(15) << "Amount" << setw(15) << "Comp Sci" << setw(15) << "Comp Sec" << endl;
    printRecord(info, size);
    return 0;
}
 
string readName()
{
    string readName;
    cin >> readName;
    return readName;
}
int readHours()
{
    int readHours;
    cin >> readHours;
    return readHours;
}
int readPayRate()
{
    int readHours;
    cin >> readHours;
    return readHours;
}
int readMajor()
{
    int ReadMajor;
    cin >> ReadMajor;
    return ReadMajor;
}
double computeAmount(int myMajor, double myPay)
{
    switch (myMajor)
    {
    case 0:
        break;
    case 1:
        myPay += 1000.0;
        break;
    }
    return myPay;
}
void printRecord(varis info[], int size)
{
    int i = 0;
    do
    {
        cout << left << setw(15) << info[i].lastName << setw(15) << info[i].firstName << setw(15)
             << info[i].hours << setw(15) << info[i].rate << setw(15) << info[i].pay;

 

        if (info[i].major_type[0] == 0)
            cout << setw(15) << 'N';
        else
            cout << setw(15) << 'Y';
        if (info[i].major_type[1] == 0)
            cout << setw(15) << 'N';
        else
            cout << setw(15) << 'Y';
        cout << endl;

 

        ++i;
    } while (i < size);
};
 
 
As you see in pp. 638-640, structures are useful to store related data together that defined with different
types. Here you are asked to modify the Payroll program that we have been working on previous labs.
You are asked to write a program using structures and pointers as shown in the following, and store the
in an output file. You may see "Appending a Node to the List" in pp. 1126-1128, and pp. 530-536.
#include <bits/stdc++.h>
using namespace std;
struct Employee_t
{
string Fname, Lname;
int NofHours;
float HourlyRate;
char Major (Computer, Security);
float Amount;
Employee *next
};
Employee *head;
void print-record (struct *);
//use setw() to align fields properly;
Last Name
ESU
CPSC
Your Name
First Name
Komp
Scien
Add 7 more of your own here... Create a file, Employee.txt.
int main()
{
}
# of Hours
30
40
40
for (int count=0; count < NumOfEmp; count++)
{.
print each line on your screen;
//Allocate a new node and store.
infile >> newNode->fname;
infile >> newNode->NofHours;
newNode-> = nullptr;
print-record(newNode);
***
Hourly Rate
40
30
35
return 0;
Amount Comp Sci
2200
Y
2200
Y
3400
Y
Comp Sec
N
N
Y
Transcribed Image Text:As you see in pp. 638-640, structures are useful to store related data together that defined with different types. Here you are asked to modify the Payroll program that we have been working on previous labs. You are asked to write a program using structures and pointers as shown in the following, and store the in an output file. You may see "Appending a Node to the List" in pp. 1126-1128, and pp. 530-536. #include <bits/stdc++.h> using namespace std; struct Employee_t { string Fname, Lname; int NofHours; float HourlyRate; char Major (Computer, Security); float Amount; Employee *next }; Employee *head; void print-record (struct *); //use setw() to align fields properly; Last Name ESU CPSC Your Name First Name Komp Scien Add 7 more of your own here... Create a file, Employee.txt. int main() { } # of Hours 30 40 40 for (int count=0; count < NumOfEmp; count++) {. print each line on your screen; //Allocate a new node and store. infile >> newNode->fname; infile >> newNode->NofHours; newNode-> = nullptr; print-record(newNode); *** Hourly Rate 40 30 35 return 0; Amount Comp Sci 2200 Y 2200 Y 3400 Y Comp Sec N N Y
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 6 steps with 2 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

can you implement it where if the major is comp sci or cyber sec it adds 1000 to their amount and if its both then it adds 2000 to their amount. 

 

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Linked List Representation
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning