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

You are given a file that contains sales data. The name of the file is Sales. Th

ID: 3568839 • Letter: Y

Question

You are given a file that contains sales data. The name of the file is Sales.

The record layout for the file is
Sales Person Id character
Sales Amount real

Example Input
111 $6385.22
444 $8916.22
111 $4882.16
222 $16402.00
333 $5110.00
111 $4600.00
333 $4999.99

Design a program that program that prompts the user to give you the Sales Person Id, then process the data in the file to get and display the total sales, average sales amount, largest sale and smallest sale for that sales person.

Example Output
Sales person XXX had totals sales of $999.99.
The average sales amount for sales person XXX was $999.99
The largest sale for sales person XXX was $999.99.
The smallest sale for sales person XXX was $999.99

CAN SOME GUIDE TO CHECK IF IS THIS THE PSEUDO CODE FOR THIS PROBLEM

Main()

     Declare Intenger PersonId

     Declare Intenger SalesAmount

     Declare InputFile EmployeeSales

     Declare Real TotalSales

     Declare Intenger Average

      Declare Intenger Max

      Declare Intenger Count1

      Declare Intenger Count2

      Declare Intenger index

      Declare Intenger LargestSale

      Declare Intenger SmallestSale

      //

     //open the sales file

     Display

Explanation / Answer

#include<iostream>
using namespace std;
// Class for holding records
class record {
public:
int sales_person_id;
float sales_amount;
};
int main()
{
int i=0;
int j,sale_id,count;
float avg_amount,max_amount,min_amount;
record rec[100]; //array of objects
// Loop for data entry in the record class
do {
cout<<"Enter sales person id";
cin>>rec[i].sales_person_id;
cout<<"Enter sales amount";
cin>>rec[i].sales_amount;
i++;
cout<<"Want to enter more records(1-yes)?";
cin>>j;
}while(j == 1);
// Enter the id of the sales person for whom record is to be searched
cout<<"Enter the sales person id";
cin>>sale_id;
avg_amount = 0.0;
count = 0;
// Loop for searchinf all the records
for(j=0;j<i;j++) {
if(rec[j].sales_person_id == sale_id) {
count++;
avg_amount = avg_amount + rec[j].sales_amount;
if(max_amount < rec[j].sales_amount) {
max_amount = rec[j].sales_amount;
}
if(count == 1) {
max_amount = rec[j].sales_amount;
min_amount = rec[j].sales_amount;
}
if(min_amount > rec[j].sales_amount) {
min_amount = rec[j].sales_amount;
}
}
}
// Printing the results
cout<<"Sales person "<<sale_id<<" had totals sales of $"<<avg_amount<<endl;
cout<<"The average sales amount for sales person "<<sale_id<<" was $"<<avg_amount/count<<endl;
cout<<"The largest sale for sales person "<<sale_id<<" was $"<<max_amount<<endl;
cout<<"The smallest sale for sales person "<<sale_id<<" was $"<<min_amount<<endl;
return 0;
}

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