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: 3552858 • 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

#include<iostream>

#include<fstream>

#include<conio.h>

#include<iomanip>

#include<cmath>

#include<string>

// 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();

void SWITCH1(int&, int&);

void SWITCH2(float&, float&);

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 count=0;

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];

count++;

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 total_agent[size];

//int total_amount[size];

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

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

int i=0;

int t=0;

cout<<fixed<<showpoint;

cout<<setprecision(2);

while(!ins.eof())

{

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

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

i++;

}

for(int n=count-2; n>=0; n--)

{

for(int m=0; m<=n; m++)

{

if(agent[n]==agent[m])

{

amount[n]+=amount[m];

sales[n]+=sales[m];

}

}

amount[n]=amount[n]/2;

sales[n]=sales[n]/2;

value[n]=amount[n]/sales[n];

}

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

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

{

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

{

SWITCH1(agent[b], agent[b+1]);

SWITCH1(sales[b], sales[b+1]);

SWITCH2(value[b], value[b+1]);

SWITCH2(amount[b], amount[b+1]);

}

}

for(int t=0; t<=count; t++)

{

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

}

cout<<endl;

ins.clear();

ins.close();

}

void SWITCH1(int& x, int& y)

{

int temp;

temp=x;

x=y;

y=temp;

}

void SWITCH2(float& x, float& y)

{

float temp;

temp=x;

x=y;

y=temp;

}

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