Question
HI, for my C++ class i am having trouble starting a project. I was wondering if you help point me in the write direction. Thanks
HI, for my C++ class i am having trouble starting a project. I was wondering if you help point me in the write direction. Thanks in advance
Pseudo code for Programming Project 2
Define prototypes for 2 void functions:
* One to sort the arrays (see below function description for header details)
* One to output the report. The parameters will be the two arrays
In the mainline :
Define at least 2 arrays : one to store Salesperson names and one to store
their monthly sales
Set the manipulators
Input data from the input file. Use logic such as :
string Salesperson[25];
int Sales[25];
int i = 0;
ifstream Infile;
Infile.open ("Project2Input.txt");
if(!Infile)
{
cout << "Unable to open input file. "<< endl;
cout << "Terminating program ! "<< endl;
return 1;
}
Infile >> Salesperson[i] >> Sales[i] ;
while ( !Infile.eof())
{
i = i + 1;
Infile >> Salesperson[i] >> Sales[i] ;
}
Infile.close();
NOTE : For the above to compile, be sure to include the fstream header !
Call the function to sort the arrays
Call the function to output the report
End program
Continued on next page
Define the 2 functions
Function to sort the arrays :
See the logic in the bubbleSort function before example 16-1 in the
textbook . In place of the list array, use the name of the Sales array. Also,
add the Salesperson array as a parameter.
Also, since we also need to sort the Salesperson array, replicate and
modify:
temp = list[index];
list[index] = list[index + 1];
list[index + 1] = temp;
so that as elements in the Sales array are moved, Salesperson elements
are also moved
Function to output the report (This is similar to problem 8-7) :
See example 8-6 in the textbook. Modify the printArray function heading
to accept two arrays (one containing the Sales and one containing
salespersons names), array size and another parameter containing the
Total_sales. NOTE : Total_sales can be calculated in the loop that
Inputs the data
Before the loop, output the heading of the report and the column
headings.
Modify the cout statement in the loop so it outputs the salesperson name,
sales, percentage and bonus.
Output the total miles line.
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