Answer to Question #311186 in C++ for Nobody

Question #311186

A company named Best Options is doing an analysis of its 10 best sales representatives. The analysis is important for the company to search for the best salesperson among them. The particular salesperson will be awarded a token of appreciation from the company. A computer program is required to assist the company in doing the analysis. Write a complete C++ program to do the following:

(a) Declare three arrays, namely StaffName of type string, StaffID of type integer and Sales of type double. The entire array’s size is 10.


(b) Prompt the user to enter the salesperson’s name, staff ID and their respective sales, and store into the arrays. Staff name will be stored in array StaffName, staff ID will be stored in array StaffID while sales will be stored in array Sales.

(c) Find and display the average sales of the 10 sales person.


(d) Print the staff name, ID and the amount of sales of the sales person with the highest sales.



1
Expert's answer
2022-03-14T08:39:05-0400
#include <iostream>
#include <string>
using namespace std;


int main() {
    const int N=10;
    string StaffName[N];
    int StaffID[N];
    double Sales[N];


    for (int i=0; i<N; i++) {
        cout << "Enter the salesperson's name: ";
        cin >> StaffName[i];
        cout << "Enter the staff ID: ";
        cin >> StaffID[i];
        cout << "Enter the sales: ";
        cin >> Sales[i];
        cout << endl;
    }


    double total=0.0;
    for (int i=0; i<N; i++) {
        total += Sales[i];
    }
    double average = total / N;
    cout << "The average sales is "<< average << endl;


    int max_indx = 0;
    for (int i=1; i<N; i++) {
        if (Sales[i] > Sales[max_indx]) {
            max_indx = i;
        }
    }
    cout << endl << "The highest sales:" << endl;
    cout << "Name: " << StaffName[max_indx]
         << ", ID: " << StaffID[max_indx] 
         << ", sales; " << Sales[max_indx] << endl;
    
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment