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

problem specification: writing in c++ language ... Question Problem Specificatio

ID: 3673382 • Letter: P

Question

problem specification: writing in c++ language ...

Question

Problem Specification: Writing in c++ language

write a program that will define a structure consisting of the following data members, “fields”:

- name

- hours worked

- hourly rate

Use a structure to implement the following:

-Use a function to read the name, hours and rate, passing them by reference to the

main function.

-Call a function to print, this function accepts the entire structure by value.

This function will call a function that will return the

grosspay, a local variable in print(function), by multiplying the hours by the rate.

The function then prints each data member on a separate line followed by the

grosspay

Input of the program:

- name(cin, getline);

- Hours worked

- Hourly rate

Output should go to a file and should be a report like follows:

Employee Name:        Jim Donavan

Hours worked:

40.00

Hourly Rate:

$      9.75

Total Wages:                                                $ 390.00

Structure implementation

10 points Good programming practices: Proper spacing, comments, use of variables, and typedef, indentation and programs appearance.

5    points Descriptive names are used.

5    points Hierarchical chart is handed-in and is correct.

5    points the function that reads the data passes the values entered back into the structure.

5    points the function that calculates, returns the gross as its value to the gross member.

5    points the function that prints accepts the entire structures value, prints all the members on a separate line each and the grosspay.

5    points test results are handed in.

10 points program designed as specified, runs and produces the correct results.

Explanation / Answer

#include <iostream>
#include <fstream>
#include<ostream>

using namespace std;

void readInput();
void print();
double grosspay(double,int);
typedef double moneyperhour;
typedef int Hours;
typedef string name;
struct employee
{
name empname;
Hours numberofhours;
moneyperhour money;

}e1;

int main()
{

int GrossPayment;
readInput();
print();

return 0;
}
void readInput()
{
cout << "enter employee name" << endl;
cin >>e1.empname;
cout<< "enter number of hours"<< endl;
cin >> e1.numberofhours;
cout <<"enter amount per hour"<<endl;
cin >> e1.money;

}
void print()
{
ofstream myfile;
myfile.open("output.txt");

myfile << "employee name :" << e1.empname << endl;
myfile << "hours worked :" << e1.numberofhours <<endl;
myfile << "hourly rate: $"<<e1.money<<endl;
myfile << "total wages :"<<grosspay(e1.money,e1.numberofhours);
myfile.close();
}
double grosspay(double m,int h)
{
return (m*h);
}