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

You are the manager of a travel agency with 20 employees. You have announced a p

ID: 3552831 • Letter: Y

Question

You are the manager of a travel agency with 20 employees. You have announced a promotional campaign for your agents to sell vacation packages. Each day you will enter the ID number of the agent (#1-#20), the number of packages sold, and the dollar value of the package. Entries will be in a random order and the total $ value is accumulated for a 3 week period. At the end of the campaign you want a print out of those agents who sold less than $1000.00 in the 3 week time frame. You will also want a list of those that did not participate in the campaign. Input and output are done using files.

Explanation / Answer

Try this::

#include<iostream>

#include<fstream>

#include<conio.h>

#include<iomanip>

#include<cmath>

// Associating program identifiers with external file names

#define in_file "data.txt"//input file name

#define out_file "result.txt"//output file name

using namespace std;

void error();

void display();

void total();

ifstream ins;// associates ins as an input stream

ofstream outs;// associates outs as an output stream

const int size=19;

int agent[size];

int sales[size];

float value[size];

float amount[size];

int main()

{

outs.open(out_file);

error();

display();

total();

getch();

outs.close();

}

void error()

{

ins.open(in_file);

cout<<"LIST OF INVALID ENTRIES"<<endl;

int i=0;

while(!ins.eof())

{

ins>>agent[i]>>sales[i]>>value[i];

cout<<fixed<<showpoint;

cout<<setprecision(2);

if((agent[i]<1)||(agent[i]>20))

{

cout<<setw(2)<<agent[i]<<" "<<setw(2)<<sales[i]<<" "<<setw(7)<<value[i];

cout<<" **invalid agent #**"<<endl;

}

else if(value[i]<0)

{

cout<<setw(2)<<agent[i]<<" "<<setw(2)<<sales[i]<<" "<<setw(7)<<value[i];

cout<<" **invalid price**"<<endl;

}

i++;

}

cout<<endl;

ins.clear();

ins.close();

}

void display()

{

ins.open(in_file);

int temp;

cout<<" TOTAL SALES BY AGENT"<<endl;

cout<<"AGENT NUMBER #SALES VALUE/SALE AMOUNT"<<endl;

int i=0;

while(!ins.eof())

{

ins>>agent[i]>>sales[i]>>value[i];

amount[i]=sales[i]*value[i];

cout<<fixed<<showpoint;

cout<<setprecision(2);

if((agent[i]>0)&&(agent[i]<21))

{

for(int a=13-2; a>=0; a--)

for(int b=0; b<=a; b++)

{

if(agent[b]>agent[b+1])

{

temp=agent[b];

agent[b]=agent[b+1];

agent[b+1]=temp;

}

}

cout<<setw(2)<<agent[i]<<" "<<setw(2)<<sales[i]<<" "<<setw(7)<<value[i]<<" "<<setw(7)<<amount[i]<<endl;

}

i++;

}

cout<<endl;

ins.clear();

ins.close();

}

void total()

{

ins.open(in_file);

int i=0;

int total_sales=0;

float average_sales;

float total_volume=0;

while(!ins.eof())

{

ins>>agent[i]>>sales[i]>>value[i];

amount[i]=sales[i]*value[i];

cout<<fixed<<showpoint;

cout<<setprecision(2);

total_sales+=sales[i];

if(amount[i]>0)

total_volume+=amount[i];

average_sales=total_volume/total_sales;

i++;

}

cout<<"TOTAL SALES "<<total_sales<<endl;

cout<<"AVERAGE SALES VALUE "<<average_sales<<endl;

cout<<"TOTAL VOLUME IN SALES "<<total_volume<<endl;

cout<<endl;

ins.clear();

ins.close();

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote