This is a two part problem. Part 1: Write a program that asks the user to enter
ID: 3556092 • Letter: T
Question
This is a two part problem.
Part 1:
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.
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]
Explanation / Answer
#include<iostream>
#include<string>
using namespace std;
int main()
{
string *name=new string[3];
double *tot=new double[3];
double sum,s;
int i;
for(i=0;i<3;i++)
{
sum=0;
cout<<"Enter in the name for salesman "<<i+1<<" ";
cin>>name[i];
cout<<"Now enter in the sales for each quarter for "<<name[i]<<endl;
cout<<"Enter in data for quarter 1:";
cin>>s;
sum+=s;
cout<<"Enter in data for quarter 2:";
cin>>s;
sum+=s;
cout<<"Enter in data for quarter 3:";
cin>>s;
sum+=s;
cout<<"Enter in data for quarter 4:";
cin>>s;
sum+=s;
tot[i]=sum;
}
cout<<endl;
for(i=0;i<3;i++)
{
cout<<"Total sales for "<<name[i]<<" is $"<<tot[i]<<".00"<<endl;
}
delete[] name;
delete[] tot;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.