Question
having trouble with C++ program #include #include #include using namespace std; struct manger{ int ID; string name; int NumOfCos; double *b; }; int main() {
having trouble with C++ program
#include
#include
#include
using namespace std;
struct manger{
int ID;
string name;
int NumOfCos;
double *b;
};
int main() {
manger M;
ifstream iFile;
iFile.open("read.txt");
//ofstream oFile("copy.read", ios::out);
while (!iFile.eof())
{
// int n;
iFile >> M.ID;
getline(iFile, M.name);
iFile >> M.NumOfCos;
cout << M.ID << " " << M.name << " " << M.NumOfCos << endl;
}
iFile.close();
return 0;
}
Input
42
1 John Curry 5 2345.34 345.40 569.89 4560.45 450.00
2 Abigail Right 0
3 Jack Monstrom 2 34569.00 3456.45
.
42 Evelyn Madim 0
Instructions
The number in the first row indicates the number of rows/managers in the file. In each row, the first number is the UIN of the manager followed by his first name and last name, the number of customers and the revenue for a month from each of his customers.
a) Write a function that prints the file into another file named Revenues. Name the file Copy_Read
b) Write a function that calculates the average revenue and the total revenue for each manager. The function should return the UIN of the manager and pass the Average revenue and Total Revenue for the manager as references.
c) Write a function that uses the function in b to create an array of average revenue and an array of total revenue for all managers. You can assume that the file may not have more than 100 rows.
d) Write a function that uses the function in b to write a file that is similar to the read file but at each row, the last two numbers are the average and Total Revenue. The new file should also have headers for all the columns and the columns should be aligned. You can assume that no first or last name is bigger than 15 characters. Name the file Revenues
e) Write a function that finds the two top managers in terms of total revenue and returns their UINs
f) Write a function that calculates the two bottom managers in terms of total revenue and returns their UINs
g) Write a function that calculates the Total Revenue for all managers.
h) Write a function that prints a report in a file. Name the file Final_Report.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started