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

C++ ONLY THANKS! USE VISUAL STUDIO COMPILER ONLY! Write a program that asks the

ID: 3572247 • Letter: C

Question

C++ ONLY THANKS!

USE VISUAL STUDIO COMPILER ONLY!

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. 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 of different data types, you cannot use one array to hold all of the 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. name[1] holds the name for the second salesman and the sales data for the second salesman would be in sales[1]… ). 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 2 quarter. See if you can solve the problem, by calculating the total sales for each salesman as the data is entered and storing only the names of the salesman and the total sales for each salesman. Consider whether this problem could actually be solved without arrays. (Exercise 1 yes, but you will need your two dimensional array for Exercise 2 below).

You must not use global variables.

^^^^OUTPUT SHOULD LOOK EXACTLY LIKE THAT!!!!^^^

THANKS!!!

Here is some sample output: Enter in the name for salesman 1 Margaret [Enter Now enter in the sales for each quarter for Margaret Enter in data for quarter 1 45676 [Enter] Enter in data for quarter 2 55768 [Enter] Enter in data for quarter 3: 98376 [Enter] Enter in data for quarter 4 109873 [Enter] Enter in the name for salesman 2 Robert [Enter] Now enter in the sales for each quarter for Robert Enter in data for quarter 1 23987 [Enter] Enter in data for quarter 2 43976 [Enter] Enter in data for quarter 3: 97658 [Enter] Enter in data for quarter 4 99876 [Enter] Enter in the name for salesman 3 Leo [Enter] Now enter in the sales for each quarter for Leo Enter in data for quarter 1 8765 [Enter] Enter in data for quarter 2 56743 Enter] Enter in data for quarter 3: 97685 [Enter] Enter in data for quarter 4: 108012 [Enter] Total sales for Margaret is $309693.00 Total sales for Robert is $265497.00 Total sales for Leo is $271205.00

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:

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