I do not have any error but when I run the program sales name 1 not print out. I am using C++.
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
void getData(string names[],double sales[3][4]); void
calTotalSales(string names[],double sales[3][4]);
int main() { double sales[3][4]; string names[3];
getData(names,sales);
calTotalSales(names,sales); return 0; }
void getData(string names[],double sales[3][4]) {
for(int i=0;i<3;i++) {
cout<<"Enter in 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 in the data for the quarter "<<j+1<<": ";
cin>>sales[i][j];
}
cout<<endl; } }
void calTotalSales(string names[],double sales[3][4]) {
double max; string name; int i;
cout << setprecision(2) << fixed;
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 << "name is " << name << endl;
cout << "Salesman " << name << " had the highest sale for the quarter " << j + 1 << " with $" << max << endl; } }