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

Write a program that asks the user to enter the names of three salesmen. The pro

ID: 3676327 • Letter: W

Question

Write a program that asks the user to enter the names of three salesmen. The program should then accept the sales produced for salesman for each quarter of the year. Display the name, and the total sales amount, of each salesman. Name your program Lab11_Exercise1.cpp. Your program should have at least three functions: Your main, a second function that reads in the salesman name and sales amounts for the quarters, and a third function that displays the results. Do not use any global variables. You will need to pass data to the functions as parameters. Extend Lab11_Exercise1.cpp such that the name, and the corresponding sales amount, of the salesman who sold the highest sales are displayed for each quarter. Your program should have at least three functions: Your main, a second function that reads in the salesman name and sales amounts for the quarters, and a third function that displays the results. Do not use any global variables. You will need to pass data to the functions as parameters.

Explanation / Answer


#include <iostream>
#include <string>

using namespace std;

int main()
{
   string names[3];
   double sales[3][4], total = 0;

   for(int i = 0 ; i <3; i++)
   {
      cout << "Enter the name of the salesman " << i + 1 << ": ";
      cin >> names[i];
    
      cout << "Now enter in the sales for each quarter for " << names[i] << endl;
    
      for(int j = 0; j < 4; j++)
      {
         cout << "Enter the data for quarter " << j + 1 << ": ";
         cin >> sales[i][j];
      }
    
      cout << endl;
   }

   cout << endl;

   double max;
   string name;
   int i;

   for(int j = 0; j < 4; j++)
   {
      max = sales[0][j];
    
      for(i = 0; i < 3; i++)
      {

       
         if(max < sales[i][j])
         {
            max = sales[i][j];
          
            name = names[i];
         }
      }
    
      cout << "Salesman " << name << " had the highest sale for the quarter " << j + 1 << " with $" << max << ".00" << endl;
   }

   cout << 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