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

s 1136 Laboratory Lesson cs 1136 Laboratory Les x ngutdallasedubbcswebdav/pid 12

ID: 3574805 • Letter: S

Question

s 1136 Laboratory Lesson cs 1136 Laboratory Les x ngutdallasedubbcswebdav/pid 1260266 dt content rid 12354461 i/courses 2168 UTD AL CS 1136 SEC114 B2991/2168 c UTDAL Part 1: Exercise 1: Problem description 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 La 11 Exerciselepp. Your should have at least three functio 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. Hint: consider using two arrays in parallel One array holds the name of the salesman (string data type) and the other array holds the sales numbers (double data type). Since the data for each salesman is different data types, you cannot use one arrayto hold all ofthe data(An array is a collection of identical data types), Arrays are considered to be parallel if one of the subscripts in each array references the same thought (e.g. namelll holds the name for the second salesman and the sales data for the second salesman would be in salesl1] Hint: It is possible to solve this problem using a two dimensional array to hold the sales data with one dimension referring to quarter and the other dimension referring to the sales amount for the CS 1136 Laboratory Lesson #11

Explanation / Answer

#include <iostream>
#include <iomanip>
using namespace std;

void inputData(string salesman[],double tSale[]) //function to compute total sales of each of three salesman
{
   int i,j;
   double total;
   double sales[4];
   for(i=0;i<3;i++)
   {
cout<<" Enter in the name for salesman "<<i+1<<":";
   cin>>salesman[i];
   cout<<" Now enter in the sales for each quarter for "<<salesman[i];
   total =0;
   for(j=0;j<4;j++)
   {
       cout<<" Enter in data for quarter "<<j+1;
       cin>>sales[j];
       total = total + sales[j];
   }
   tSale[i] =total;
}
}
void displayData(string salesman[],double tSale[]) //function to display total sales of each salesman
{
   int i;
   for(i=0;i<3;i++)
   {
       cout<<" Total sale for "<<salesman[i]<<" is $"<<tSale[i];
   }
}
int main()
{
  
   string salesman[3];
   double tSale[3];
   inputData(salesman,tSale);
  
   cout<<fixed<<setprecision(2);
   displayData(salesman,tSale);
  
   return 0;
}

output: