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

C++ coding problem everything was fine but when I run the program sales 1 name i

ID: 3573381 • Letter: C

Question

C++ coding problem

everything was fine but when I run the program sales 1 name is not print out

can you guys fixed the error for me?? here is my code


#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

//Function declarations
void getData(string names[],double sales[3][4]);
void calTotalSales(string names[],double sales[3][4]);

int main()
{
//Creating an string array of size 3
string names[3];

//Creating a double array
double sales[3][4];

//Calling the functions
getData(names,sales);
calTotalSales(names,sales);
return 0;
}
//Function implementation which will get the inputs entered by the user
void getData(string names[],double sales[3][4])
{
/* This for loop will get the names and sales
* in each quarters entered by the user and
* populate them into arrays
*/
for(int i=0;i<3;i++)
{
//Getting the name entered by the user
cout<<"Enter in the name of the salesman "<<i+1<<": ";
cin>>names[i];

//Getting the sales in each quarter entered by the user
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;
}
}

/* Function implementation which will calculate
* and display the total sales made by each
* person in 4 quarters
*/
void calTotalSales(string names[],double sales[3][4])
{
//Declaring variable
double max;
string name;
int i;


/* This for loop will calculate each person
* total sales and display it one the console
*/
cout << setprecision(2) << fixed;

for(int j=0;j<4;j++)
{
//Calculating the total sales in 4 quarters
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 << endl;
}
}

Explanation / Answer

#include #include using namespace std; int main() { string names[3]; double sales[3][4], total = 0; for(int i = 0 ; i
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