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

Please do not sophiscated code for this program. Please use comments and follow

ID: 3790249 • Letter: P

Question

Please do not sophiscated code for this program. Please use comments and follow all the directions below. Professor wants us to utilize functions, bubble sort, and structure in this program. The output should be sent to a file.

You are to write a C++ program to produce an inventory report for a local company. Your input will be item name, item number, quantity, price per item, safe stock value. The following shows which columns the input will be in:

item name             item number         quantity                  price                      safe stock

20 chars                 5 char                     3 char                      6 chars                 3 chars

Output will be as follows:

item number         item name    quantity   price     price*quantity   %ofStock    flag

You will put a symbol in the flag field it he inventory quantity is less than the safe stock value.

This tells the company that they are getting too low on this item and need to build up the stock.

Print the report in sorted ordered, sorted on item number.

Indicate the total value of the stock.

Indicate the percentage of total inventory value to the total value of the highest single item in inventory. Print the item and its information. (Print this item again at the end of the table.)

You must use the struct data structure and functions. Use Bubble Sort method to sort.

Use ‘typedef’ for array declarations. The output should be printed to a file.

Read the data in from invt.txt.

invt.txt shows the following data inside the file:

Wong Batts              98723     243 6.45      200
Widgets No Two          83209     970 17.50     800
HumpBack Whale Songs    74329     42   23.70     50
Frozen Ice Cubes        73922     100 0.15      250
Plastic Ice Cubes       10044     450 0.60      540
Canned Solar Winds      23923     12   550.00    5
Sented Toe Jamm         18492     14   0.50      20
UnSented Toe Jam        18499     23   .74       20
Backwards Left Turns    87293     5    34.95     12
El Slick Slider         38324     15   225.00    18
Meals for Up Chuck      62042     20   16.50     24
Super House Cleaner     71083     14   69.85     18
Stars Dancing Shoes     23934     80   22.50     75
LowRider Briches        98744     138 45.95     125
HighRider Shoes         12283     372 35.95     400
Colored Pie Charts      51121     60   1.50      30
LensLess Saftey Glas    44433     22   2.10      35
Used Boat Anchors       73277     6    17.50     7

Explanation / Answer

include <iostream>
#include <fstream>  
#include <iomanip>
#include <string>
using namespace std;

const int EMP_NUM = 5;
const int BASE_HOURS = 40;
const char N_SIZE = 8;

int main()
{
int i;
double rEarnings, oEarnings, tEarnings,
trEarnings, toEarnings, ttEarnings;
ifstream inFile;
ofstream outFile;
inFile.open("records.txt");
outFile.open("report.txt");

outFile << setprecision(2) << showpoint << fixed;

outFile << setw(50) << "Payroll Report" << " ";
outFile << "EMPLOYEE NAME" << setw(25) << "REGULAR EARNINGS" << setw(25) << "OVERTIME EARNINGS" << setw(25) << "TOTAL EARNINGS" << endl;

string nameAr[EMP_NUM];
int hoursAr[EMP_NUM];
double hrateAr[EMP_NUM];

for (int i = 0; i < EMP_NUM; i++) // Get input from our input file.
{
inFile.getline(nameAr[i], EMP_NUM, "*");
inFile >> hoursAr[i] >> hrateAr[i];
}

for (int i = 0; i < EMP_NUM; i++) // Make the calculations to be sent to our report.
{
char nameAr[N_SIZE];
int hoursAr[N_SIZE];
double hrateAr[N_SIZE];

if (hoursAr[i] > 40) // For employees with overtime hours.
{
// double rEarnings, double oEarnings, double tEarnings,
// double trEarnings, double toEarnings, double ttEarnings;
// rEarnings = 0, oEarnings = 0, tEarnings = 0,
// trEarnings = 0, toEarnings = 0, ttEarnings = 0;

   rEarnings = BASE_HOURS * hrateAr[i];
   oEarnings = (hoursAr[i] - BASE_HOURS) * hrateAr[i] * 1.5;
   tEarnings = rEarnings + oEarnings;
   trEarnings += rEarnings;
   toEarnings += oEarnings;
   ttEarnings += tEarnings;
   outFile << left << nameAr[i];
   // << setw(25) << right << rEarnings << setw(25) << right << oEarnings << setw(25) << right << tEarnings << endl;

}
else // For employees without overtime hours.
{
   double rEarnings, double oEarnings, double tEarnings,
   double trEarnings, double toEarnings, double ttEarnings;
   rEarnings = 0, oEarnings = 0, tEarnings = 0,
   trEarnings = 0, toEarnings = 0, ttEarnings = 0;

   rEarnings = hoursAr[i] * hrateAr[i];
   oEarnings = 0;
   tEarnings = rEarnings + oEarnings;
   trEarnings += rEarnings;
   toEarnings += oEarnings;
   ttEarnings += tEarnings;
   outFile << left << nameAr[i] << setw(25) << right << rEarnings << setw(25) << right << oEarnings << setw(25) << right << tEarnings << endl;
}
}

outFile << endl << endl;

outFile << setw(33) << trEarnings << " *" << setw(23) << toEarnings << " *" << setw(23) << ttEarnings << " * ";

outFile << left << "TOTAL EMPLOYEES" << " " << (i - 1);

inFile.close(); outFile.close();

return 0;
}